This is a migrated thread and some comments may be shown as answers.

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

1 Answer 70 Views
PropertyGrid
This is a migrated thread and some comments may be shown as answers.
Tayyaba
Top achievements
Rank 1
Tayyaba asked on 06 Oct 2017, 10:47 AM

Hi,

 

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.

 

Regards,

Tayyaba

1 Answer, 1 is accepted

Sort by
0
Vladimir Stoyanov
Telerik team
answered on 11 Oct 2017, 09:12 AM
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.

Regards,
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.
Tags
PropertyGrid
Asked by
Tayyaba
Top achievements
Rank 1
Answers by
Vladimir Stoyanov
Telerik team
Share this question
or