Add a RadPropertyGrid and change its Dock property to Fill. Use the following code: public partial class Form1 : Form { RadPropertyStore _store; public Form1() { InitializeComponent(); this.radPropertyGrid1.CreateItemElement += new CreatePropertyGridItemElementEventHandler(this.onCreateItemElement); _store = new RadPropertyStore(); PropertyStoreItem barItem = new PropertyStoreItem(typeof(Int32), "TrackBar", 25); _store.Add(barItem); PropertyStoreItem sec = new PropertyStoreItem(typeof(bool), "Checkr", true); _store.Add(sec); this.radPropertyGrid1.SelectedObject = _store; } private void onCreateItemElement(object sender, CreatePropertyGridItemElementEventArgs e) { PropertyGridItem item = e.Item as PropertyGridItem; if (item != null) { if (item.Name == "TrackBar") { e.ItemElementType = typeof(TrackBarPropertyGridItem); } } } } public class TrackBarPropertyGridItem : PropertyGridItemElement { protected override PropertyGridValueElement CreatePropertyGridValueElement() { return new CustomPropertyGridValueElement(); } } public class CustomPropertyGridValueElement : PropertyGridValueElement { RadTrackBarElement _trackbar; public RadTrackBarElement Trackbar { get { return this._trackbar; } } protected override void CreateChildElements() { base.CreateChildElements(); _trackbar = new RadTrackBarElement(); _trackbar.Minimum = 0; _trackbar.Maximum = 100; this.DrawText = false; this.Children.Add(_trackbar); } } When resizing the form, the applications hangs. Workaround: /// <summary> /// Track bar property grid element /// </summary> public class TrackBarPropertyGridItem : PropertyGridItemElement { class MyTrackBarElement : RadTrackBarElement { protected override void OnNotifyPropertyChanged(string propertyName) { if (propertyName == "TickOffSet" || propertyName == "ThumbSize") { this.BodyElement.ScaleContainerElement.InvalidateMeasure(); this.BodyElement.IndicatorContainerElement.InvalidateMeasure(); return; } base.OnNotifyPropertyChanged(propertyName); } protected override Type ThemeEffectiveType { get { return typeof(RadTrackBarElement); } } } /// <summary> /// The trackbar element to be displayed in the cell /// </summary> private RadTrackBarElement _trackbar; /// <summary> /// Accessor to the track bar element /// </summary> public RadTrackBarElement Trackbar { get { return _trackbar; } } /// <summary> /// Create child elements of the propertyGridItem /// </summary> protected override void CreateChildElements() { base.CreateChildElements(); _trackbar = new MyTrackBarElement(); _trackbar.Minimum = 0; _trackbar.Maximum = 100; _trackbar.ShowTicks = false; this.ValueElement.DrawText = false; this.ValueElement.Children.Add(this._trackbar); } /// <summary> /// Synchronise the value with property grid item /// </summary> public override void Synchronize() { base.Synchronize(); PropertyGridItem item = this.Data as PropertyGridItem; this._trackbar.Value = (int)item.Value; } /// <summary> /// Add editor override /// </summary> /// <param name="editor">input editor</param> public override void AddEditor(IInputEditor editor) { } /// <summary> /// Remove editor override /// </summary> /// <param name="editor">input editor</param> public override void RemoveEditor(IInputEditor editor) { } /// <summary> /// Check if the item is comptable with trackbar editor /// </summary> /// <param name="data">item to check</param> /// <param name="context">context</param> /// <returns>true if compatible, false otherwise</returns> public override bool IsCompatible(PropertyGridItemBase data, object context) { PropertyGridItem item = data as PropertyGridItem; return (item != null && item.PropertyType == typeof(int)); } /// <summary> /// Get the type of the property grid element /// </summary> protected override Type ThemeEffectiveType { get { return typeof(PropertyGridItemElement); } }
Please refer to the attached video illustrating the incorrect behavior of the context menu. Workaround: public RadForm1() { InitializeComponent(); this.radPropertyGrid1.SelectedObject = this; this.radPropertyGrid1.ToolbarVisible = true; this.radPropertyGrid1.RadContextMenu = new CustomPropertyGridDefaultContextMenu(this.radPropertyGrid1.PropertyGridElement.PropertyTableElement); } public class CustomPropertyGridDefaultContextMenu : Telerik.WinControls.UI.PropertyGridDefaultContextMenu { PropertyGridTableElement tableElement; public CustomPropertyGridDefaultContextMenu(PropertyGridTableElement propertyGridElement) : base(propertyGridElement) { tableElement = propertyGridElement; } protected override void OnDropDownOpening(CancelEventArgs args) { base.OnDropDownOpening(args); PropertyGridItemBase item = this.tableElement.SelectedGridItem; if (item != null) { if (!(item is PropertyGridGroupItem)) { this.EditMenuItem.Visibility = ElementVisibility.Visible; this.ResetMenuItem.Visibility = ElementVisibility.Visible; } } } }
How to reproduce: run the attached project on a system with an increased scaling - 200%
To reproduce: Public Class RadForm1 Sub New() InitializeComponent() RadPropertyGrid1.SelectedObject = New MyProperties End Sub Public Class MyProperties Private _height As Integer = 70 <Browsable(True)> <Category("Rows")> <DisplayName("Height")> _ <Description("Sets the height of the row. Range 70 to 200.")> _ <RadRange(70, 200)> _ Public Property Height() As Integer Get Return _height End Get Set(ByVal Value As Integer) _height = Value End Set End Property End Class End Class When you activate the editor you will notice that you are allowed to enter values outside the specified range 7-200. Workaround: AddHandler Me.RadPropertyGrid1.EditorInitialized, AddressOf PropertyGridEditorInitialized Private Sub PropertyGridEditorInitialized(sender As Object, e As PropertyGridItemEditorInitializedEventArgs) Dim spinEditor As PropertyGridSpinEditor = TryCast(e.Editor, PropertyGridSpinEditor) If spinEditor IsNot Nothing Then spinEditor.MinValue = 70 spinEditor.MaxValue = 200 End If End Sub
When you have a property that is bool? or ToggleState, it would be good to have three-state functionality for the PropertyGridCheckBoxItemElement.
Please run the sample project on a monitor with 150 DPI scaling. You will notice that the first time the drop down is not scaled properly and it is clipped. However, each next opening of the drop down, the popup is scaled correctly:
How to create a PropertyGrid and initialize it like this,modify the 'segments' arraies as I modify the 'count'
I know that there is a RadRange Attribute but using it creates a dependency on Telerik.
Consider the scenario that the object to be configured via RadPropertyGrid is defined in a library that is used by multiple projects.
Steps to reproduce: 1. Add a RadPropertyGrid to a form. 2. Set the SelectedObjects property to a array of one object that has a property decorated with the ReadOnly attribute. Run the project and you will see that the read only property is not displayed.
Steps to reproduce: 1. Create a custom type descriptor for an object that returns less properties than the default one. 2. Set this descriptor to the object 3. Set an object array containing two such objects to the SelectedObjects property of RadPropertyGrid 4. Run the project and you will see all properties of the object are shown disrespecting the custom type descriptor.
Currently RadPropertyGrid uses CurrentUICulture for localization, while it should use CurrentCulture.
Steps to reproduce: 1. Set a PasswordPropertyText(true) attribute to a string property of an object. 2. Set the object as selected of a property grid. 3. Open the password property for edit. Any other text property you try to edit will be handled as if it was password.
When a property has a TypeConverter which method GetStandardValuesExclusive returns false. Users should be able to enter additional values, other than the values returned by the GetStandardValues mehtod.
Add the ability to handle collection items in the RadPropertyGrid.
When the spin editor is opened in the RadPropertyGrid the default min and max values should be the min and max values of the type of the property that is being edited.
Currently when expanding an item in RadPropertyGrid the order of the sub items changes on every start.
The RadPropertyGrid editing mechanism can be improved by adding ValueChanged/ing events similar to those in RadGridView.
When applied to a property the editor for this property should show its text as a password.
To reproduce: - Click on a property (with a dropdown editor for example) to start edit. - Move mouse over vertical center dividing line to get mouse to transition to resize pointer. - Move mouse to the right back over the combo box that has been activated for edit. - The mouse pointer will not transition back to the arrow, it will stay on the resize pointer.
To reproduce: - Create a property store and add some items to it. - Start the project and click an item. Workaround: - Add RadSortOrderAttribute to each item: for (int i = 0; i < propStore.Count; i++) { PropertyStoreItem item = propStore[i]; item.Attributes.Add(new RadSortOrderAttribute(i)); }