How to resize the width of EnumFlagEditor to the width of RadPropertyGrid

2 posts, 0 answers
  1. Tayyaba
    Tayyaba avatar
    21 posts
    Member since:
    Apr 2017

    Posted 06 Oct 2017 Link to this post



    I need to resize the width of FlagEnumEditor whenever propertyGrid is resized, i want to set the new width of propertyGrid to the FlagEnumEditor.

    Because if I wont set the propertyGrid width to it, then when more items are checked in FlagEnumEditor its width exceeds the propertyGrid limits and a horizontal scrollbar starts appearing, i dont want a scrollbar, i just want to restrict the FlagEnumEditor's width to the width of PropertyGrid specially when PropertyGrid is resized.




  2. Vladimir Stoyanov
    Vladimir Stoyanov avatar
    113 posts

    Posted 11 Oct 2017 Link to this post

    Hi Tayyaba,

    Let me clarify a few things first. The element in which RadPropertyGrid displays properties is PropertyGridField, FlagEnumEditor is an editor which supports editing bit flag enum. I suppose that when you use FlagEnumEditor in your post you mean PropertyGridField. Feel free to correct me if I am wrong.

    You can subscribe to RadPropertyGrid's Loaded event to set the the width of the PropertyGridField that is wider than the RadPropertyGrid like so:
    private void rpg_Loaded(object sender, RoutedEventArgs e)
                var longField = this.PropertyGrid1.ChildrenOfType<PropertyGridField>().FirstOrDefault();
                longField.Width = ((RadPropertyGrid)sender).ActualWidth;
    This would adjust the width of the first PropertyGridField to the width of the RadPropertyGrid. Feel free to change that code if you need to adjust more than one field.

    If you need to resize the fields every time the RadPropertyGrid is resized you can subscribe to its SizeChanged event and adjust the width of the fields there.

    I hope you find this helpful. Let me know if I can be of any further assistance.

    Vladimir Stoyanov
    Progress Telerik
    Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Back to Top