AlphabeticalToggleButton is not drawn correctly on 150% DPI. This is observed in the VisualStudio2022Light theme. In Fluent theme, the button is drawn correctly.
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.
How to create a PropertyGrid and initialize it like this,modify the 'segments' arraies as I modify the 'count'
Hello,
RadPropertyGrid does not properly intersect properties when what is set as SelectedObjects implements the ICustomTypeDescriptor interface. However, the .Net Framework PropertyGrid does not have this problem.
To reproduce the problem, use the attached project.
When setting SelectedObject a ReadOnlyAttribute applies to the grid. But when wrapping it in an object[] and assign it to SelectedObjects the grid allows editing.
Sample application included.
Currently, the only possible way to set the value to null is to select the whole text and press the Delete key.
If the value is cleared by the backspace key, it is restored when the control loses focus.
If the value is cleared by multiple times clicking the delete key and the cursor is in the first position, the previous value is restored when the control loses focus.
Workaround:
Subscribe to the TextChanged event of the spin editor and explicitly set the NullableValue of the BaseSpinEditorElement:
this.radPropertyGrid1.EditorInitialized += this.RadPropertyGrid1_EditorInitialized;
private void RadPropertyGrid1_EditorInitialized(object sender, PropertyGridItemEditorInitializedEventArgs e)
{
if (e.Editor is PropertyGridSpinEditor spinEdit)
{
if (spinEdit.EditorElement is BaseSpinEditorElement editorElement && editorElement.EnableNullValueInput)
{
editorElement.TextChanged -= this.EditorElement_TextChanged;
editorElement.TextChanged += this.EditorElement_TextChanged;
}
}
}
private void EditorElement_TextChanged(object sender, EventArgs e)
{
if (sender is BaseSpinEditorElement editorElement && string.IsNullOrWhiteSpace(editorElement.Text))
{
editorElement.NullableValue = null;
}
}
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:
Workaround: Private Sub RadPropertyGrid1_EditorRequired(sender As Object, e As PropertyGridEditorRequiredEventArgs) Handles RadPropertyGrid1.EditorRequired Dim te As PropertyGridTableElement = TryCast(sender, PropertyGridTableElement) If e.EditorType = GetType(PropertyGridSpinEditor) Then Dim editor As New CustomPropertyGridSpinEditor If editor IsNot Nothing AndAlso te IsNot Nothing Then Dim type As Type = RadPropertyGrid1.SelectedObject.[GetType]().GetProperty(e.Item.Name).PropertyType If type = GetType(System.Double) Then DirectCast(editor.EditorElement, BaseSpinEditorElement).DecimalPlaces = 4 e.Editor = editor End If End If End If End Sub Public Class CustomPropertyGridSpinEditor Inherits PropertyGridSpinEditor Public Overrides Sub Initialize(owner As Object, value As Object) Dim decimalPlaces As Integer = Me.DecimalPlaces MyBase.Initialize(owner, value) Dim element As PropertyGridItemElement = TryCast(owner, PropertyGridItemElement) Dim item As PropertyGridItem = TryCast(element.Data, PropertyGridItem) Dim editedType As Type = item.PropertyType If ((editedType = GetType(Decimal) OrElse editedType = GetType(Double) OrElse editedType = GetType(Single)) AndAlso decimalPlaces <> 0) Then DirectCast(Me.EditorElement, BaseSpinEditorElement).DecimalPlaces = decimalPlaces Me.Value = value End If End Sub End Class
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
Hello,
we are trying to use RadPropertyGrid to show the properties of some objects listed in a RadGrdiView.
We use ExpandableObject to expand our custom property, but we have some problems when we try to show the properties of multiple selected items, when the values of the attribute of the property are not the same in all the selected objects. We tried to use PropertyGrid of Winform and we don't have this problem.
Thank you.
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 }); } }