The clients needs to use a PropertyGridDropDownListEditor and confirms the new value whenever a new selection is made. The attached gif file illustrates how to replicate the error using the following code snippet:
public RadForm1()
{
InitializeComponent();
this.radPropertyGrid1.SelectedObject = this;
this.radPropertyGrid1.EditorInitialized += radPropertyGrid1_EditorInitialized;
}
private void radPropertyGrid1_EditorInitialized(object sender, PropertyGridItemEditorInitializedEventArgs e)
{
PropertyGridDropDownListEditor ddl = e.Editor as PropertyGridDropDownListEditor;
if (ddl != null)
{
ddl.LoopValuesOnDoubleClick = false;
BaseDropDownListEditorElement element = ddl.EditorElement as BaseDropDownListEditorElement;
if (element != null)
{
element.SelectedValueChanged -= Element_SelectedValueChanged;
element.SelectedValueChanged += Element_SelectedValueChanged;
}
}
}
private void Element_SelectedValueChanged(object sender, Telerik.WinControls.UI.Data.ValueChangedEventArgs e)
{
this.radPropertyGrid1.EndEdit();
}Workaround:
public RadForm1()
{
InitializeComponent();
this.radPropertyGrid1.SelectedObject = this;
this.radPropertyGrid1.ValueChanged += RadPropertyGrid1_ValueChanged;
}
private void RadPropertyGrid1_ValueChanged(object sender, EventArgs e)
{
if (this.radPropertyGrid1.ActiveEditor is PropertyGridDropDownListEditor)
{
this.radPropertyGrid1.EndEdit();
}
}
Problem: I'd like to filter the properties to be displayed by their category names defined by the Category attribute. Based on the doc here (https://docs.telerik.com/devtools/winforms/controls/propertygrid/features/filtering), my understanding is to add a FilterDescriptor like this: New FilterDescriptor ("Category", FilterOperator.Contains, "some category name"). But it turned out to only filter by property name, not category name. Any misunderstanding or possible issue? Thank you for looking into this.
Reproduce:
1. Define a class like this:
Private Class TestClass
<Category("Cat1")> Public Property Property1 As Integer = 1
<Category("Cat1")> Public Property Property2 As String = "Test 2"
<Category("Cat2")> Public Property Property3 As String = "Test 3"
End Class
2. Initialize a RadPropertyGrid in the Form.Load event:
Dim testObj As New TestClass
RadPropertyGrid1.EnableFiltering = True
Dim filter As New FilterDescriptor("Category", FilterOperator.Contains, "2")
RadPropertyGrid1.FilterDescriptors.Add(filter)
RadPropertyGrid1.SelectedObject = testObj
3. The right property to be displayed should be Property3, but it turned out to be Property2
Example project: attached.
Thank you team!
Use the following code snippet and try to edit the Height. You will notice that the sub-items' order is changed:

RadPropertyStore store = new RadPropertyStore();
PropertyStoreItem sizeItem = new PropertyStoreItem(typeof(System.Drawing.Size), "Size", new System.Drawing.Size(100, 25), "The size of the control in pixels.", "Layout");
store.Add(sizeItem);
this.radPropertyGrid1.SelectedObject = store;
this.radPropertyGrid1.SortOrder = SortOrder.Ascending;
this.radPropertyGrid1.PropertySort = PropertySort.Alphabetical;
1. Create a custom property item
2. Enable grouping
3.Scroll up and down
4.NullReferenceException occurs
Currently, the ExpandableObjectConverter is the appropriate solution for adding nested properties in RadPropertyGrid. Using TypeConverters is quite a flexible mechanism that RadPropertyGrid offers: https://docs.telerik.com/devtools/winforms/controls/propertygrid/type-converters
It would be nice to have a more flexible and easy approach, e.g. PropertyStoreItem .Items collection that allows you to add nested properties.
To reproduce: run the attached sample project and follow the steps from the gif file.
Workaround: cancel the edit operation when handling the MouseDown event of RadPropertyGrid:
private void radPropertyGrid1_MouseDown(object sender, MouseEventArgs e)
{
var elementUnderMouse = this.radPropertyGrid1.ElementTree.GetElementAtPoint(e.Location).FindAncestor<RadScrollBarElement>();
if (elementUnderMouse!=null)
{
this.radPropertyGrid1.CancelEdit();
}
}
Use the editor from the following article to reproduce: https://docs.telerik.com/devtools/winforms/propertygrid/editors/using-custom-editor
Workaround:
void TrackBarEditor_ValueChanged(object sender, EventArgs e)
{
PropertyGridItemElement owner = this.OwnerElement as PropertyGridItemElement;
if (owner != null)
{
var method = owner.PropertyTableElement.GetType().GetMethod("OnValueChanged", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
method.Invoke(owner.PropertyTableElement, new object[] { this, EventArgs.Empty });
}
}
When you have a property that is bool? or ToggleState, it would be good to have three-state functionality for the PropertyGridCheckBoxItemElement.
Office2010silver theme showing different result with 2017.2.613 version my font size became very small.
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
Use attached to reproduce. Workaround radPropertyGrid1.ItemSpacing = 1;
To reproduce:
this.radPropertyGrid1.SelectedObject = this;
this.radPropertyGrid1.PropertyGridElement.SplitElement.HelpElement.MinSize = new Size(0, 60);
Please refer to the attached gif file.
Workaround:
this.radPropertyGrid1.SelectedObject = this;
this.radPropertyGrid1.PropertyGridElement.SplitElement.HelpElement.MinSize = new Size(0, 60);
this.radPropertyGrid1.PropertyGridElement.SplitElement.HelpElement.HelpTitleElement.MinSize = new Size(0,20);
this.radPropertyGrid1.PropertyGridElement.SplitElement.HelpElement.HelpTitleElement.PropertyChanged += HelpTitleElement_PropertyChanged;
private void HelpTitleElement_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == "Bounds")
{
if (this.radPropertyGrid1.PropertyGridElement.SplitElement.HelpElement.HelpContentElement.Location.Y != 20)
{
this.radPropertyGrid1.PropertyGridElement.SplitElement.HelpElement.HelpContentElement.Location = new Point(0, 20);
}
}
}
Note: the description element may be floating but it doesn't overlap the title.
How to reproduce: associate the control with an object having a Font property. It can be the form itself, then try and change the font-size, e.g: -1.
The standard property grid displays a message box with the error.
Workaround handle the RadPropertyGrid.EditorInitialized event:
private void RadPropertyGrid_EditorInitialized(object sender, PropertyGridItemEditorInitializedEventArgs e)
{
PropertyGridSpinEditor editor = e.Editor as PropertyGridSpinEditor;
if (editor != null && e.Item.Parent != null && e.Item.Parent.Name == "Font" && e.Item.Name == "Size")
{
editor.MinValue = 1;
}
}
This should work similar to RadGridView. Once should be able to manually set the height of on individual rows as well.
The incorrect behavior is also observed if the SelectedObject is changed.
How to reproduce:
public partial class RadForm1 : RadForm
{
public RadForm1()
{
this.InitializeComponent();
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
this.radPropertyGrid1.EnableSorting = true;
this.radPropertyGrid1.SelectedObject = new TestObject();
foreach (var item in this.radPropertyGrid1.Items)
{
if (item.Name == "A")
{
item.SortOrder = 2;
}
else if (item.Name == "B")
{
item.SortOrder = 1;
}
else
{
item.SortOrder = 0;
}
}
this.radPropertyGrid1.PropertySort = PropertySort.NoSort;
}
}
public class TestObject
{
public int A { get; set; }
public int C { get; set; }
public int B { get; set; }
}
Workaround:
1. Use attributes in the model class:
public class TestObject
{
[RadSortOrder(2)]
public int A { get; set; }
[RadSortOrder(0)]
public int C { get; set; }
[RadSortOrder(1)]
public int B { get; set; }
}
2. Alternatively, toggle the PropertySort property in the Shown event of the form:
public partial class RadForm1 : RadForm
{
public RadForm1()
{
this.InitializeComponent();
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
this.radPropertyGrid1.EnableSorting = true;
this.radPropertyGrid1.SelectedObject = new TestObject();
foreach (var item in this.radPropertyGrid1.Items)
{
if (item.Name == "A")
{
item.SortOrder = 2;
}
else if (item.Name == "B")
{
item.SortOrder = 1;
}
else
{
item.SortOrder = 0;
}
}
this.radPropertyGrid1.PropertySort = PropertySort.NoSort;
}
protected override void OnShown(EventArgs e)
{
base.OnShown(e);
this.radPropertyGrid1.PropertySort = PropertySort.Alphabetical;
this.radPropertyGrid1.PropertySort = PropertySort.NoSort;
}
}
public class TestObject
{
public int A { get; set; }
public int C { get; set; }
public int B { get; set; }
}
Use attached to reproduce. - Type 'n' in the search bar - "Name" is not found
How to reproduce: run the attached project on a system with an increased scaling - 200%
To reproduce: use the following code snippet and follow the steps from the gif file:
PropertyStoreItem item1 = new PropertyStoreItem(typeof(string), "Test1", "Test1");
PropertyStoreItem item2 = new PropertyStoreItem(typeof(string), "Test2", "Test2");
RadPropertyStore store = new RadPropertyStore();
store.Add(item1);
store.Add(item2);
this.radPropertyGrid1.SelectedObject = store;
this.radPropertyGrid1.ToolbarVisible = true;
Workaround: close the editor programmatically when the search box gets focus.
this.radPropertyGrid1.PropertyGridElement.ToolbarElement.SearchTextBoxElement.TextBoxItem.GotFocus += TextBoxItem_GotFocus;
private void TextBoxItem_GotFocus(object sender, EventArgs e)
{
this.radPropertyGrid1.EndEdit();
}
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: check the attached screenshot Workaround: use the attached custom theme