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'
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:
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();
}
}
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;
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.
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; } }
To reproduce: Sub New() InitializeComponent() Dim intItem As New PropertyStoreItem(GetType(Integer), "Integer", 1) Dim floatItem As New PropertyStoreItem(GetType(Single), "Float", 1.0F, "Property storing a floating point value.") Dim stringItem As New PropertyStoreItem(GetType(String), "String", "telerik", "Property storing a string value", "Telerik") Dim fontItem As New PropertyStoreItem(GetType(Font), "Font", New Font("Arial", 12, FontStyle.Italic), "Property containing Font value") fontItem.Attributes.Add(New ReadOnlyAttribute(True)) floatItem.Attributes.Add(New ReadOnlyAttribute(True)) Dim store As New RadPropertyStore store.Add(intItem) store.Add(floatItem) store.Add(stringItem) store.Add(fontItem) Me.RadPropertyGrid1.SelectedObject = store End Sub Try to edit either the "Float" or the "Font" property. The editor will be activated although it doesn't have to. Workaround: cancel the Editing event Private Sub RadPropertyGrid1_Editing(sender As Object, e As PropertyGridItemEditingEventArgs) If e.Item.Name = "Font" Then e.Cancel = True End If End Sub
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%
Workaround: public class CustomPropertyGrid : RadPropertyGrid { public override string ThemeClassName { get { return typeof(RadPropertyGrid).FullName; } } protected override PropertyGridElement CreatePropertyGridElement() { return new CustomPropertyGridElement(); } } public class CustomPropertyGridElement : PropertyGridElement { protected override Type ThemeEffectiveType { get { return typeof(PropertyGridElement); } } protected override PropertyGridSplitElement CreateSplitElement() { return new CustomPropertyGridSplitElement(); } } public class CustomPropertyGridSplitElement : PropertyGridSplitElement { protected override Type ThemeEffectiveType { get { return typeof(PropertyGridSplitElement); } } protected override PropertyGridTableElement CreateTableElement() { return new CustomPropertyGridTableElement(); } } public class CustomPropertyGridTableElement:PropertyGridTableElement { protected override Type ThemeEffectiveType { get { return typeof(PropertyGridTableElement); } } public override bool ProcessKeyDown(KeyEventArgs e) { if (e.KeyData == Keys.Enter && ((PropertyGridItem)this.SelectedGridItem).PropertyType == typeof(bool)) { PropertyGridItem item = this.SelectedGridItem as PropertyGridItem; item.Value = !(bool)item.Value; return true; } return base.ProcessKeyDown(e); } }
Currently editors not shown as dialog do not work as the RadPropertyGrid editor is closed when focus is transferred to the dialog form.
To reproduce: public Form1() { InitializeComponent(); this.radPropertyGrid1.SelectedObject = new Item(123,"Item123",DateTime.Now.AddDays(20)); this.radPropertyGrid1.EditorInitialized += radPropertyGrid1_EditorInitialized; } private void radPropertyGrid1_EditorInitialized(object sender, Telerik.WinControls.UI.PropertyGridItemEditorInitializedEventArgs e) { PropertyGridDateTimeEditor propertyGridDateTimeEditor = e.Editor as PropertyGridDateTimeEditor; if (propertyGridDateTimeEditor != null) { BaseDateTimeEditorElement dateTimeEditorElement = propertyGridDateTimeEditor.EditorElement as BaseDateTimeEditorElement; if (dateTimeEditorElement != null) { dateTimeEditorElement.Format = DateTimePickerFormat.Long; dateTimeEditorElement.ShowTimePicker = true; var radDateTimePickerCalendar = dateTimeEditorElement.CurrentBehavior as RadDateTimePickerCalendar; if (radDateTimePickerCalendar != null) { radDateTimePickerCalendar.DropDownMinSize = new System.Drawing.Size(600, 400); } } } } public class Item { public int Id { get; set; } public string Name { get; set; } public DateTime Date { get; set; } public Item(int id, string name, DateTime date) { this.Id = id; this.Name = name; this.Date = date; } } Workaround: private void radPropertyGrid1_EditorInitialized(object sender, Telerik.WinControls.UI.PropertyGridItemEditorInitializedEventArgs e) { PropertyGridDateTimeEditor propertyGridDateTimeEditor = e.Editor as PropertyGridDateTimeEditor; if (propertyGridDateTimeEditor != null) { BaseDateTimeEditorElement dateTimeEditorElement = propertyGridDateTimeEditor.EditorElement as BaseDateTimeEditorElement; if (dateTimeEditorElement != null) { dateTimeEditorElement.Format = DateTimePickerFormat.Long; dateTimeEditorElement.ShowTimePicker = true; var radDateTimePickerCalendar = dateTimeEditorElement.CurrentBehavior as RadDateTimePickerCalendar; if (radDateTimePickerCalendar != null) { radDateTimePickerCalendar.PopupControl.PopupOpened-=PopupControl_PopupOpened; radDateTimePickerCalendar.PopupControl.PopupOpened+=PopupControl_PopupOpened; } } } } private void PopupControl_PopupOpened(object sender, EventArgs args) { RadDateTimePickerDropDown dropdown = sender as RadDateTimePickerDropDown; dropdown.MinimumSize = new Size(600, 300); }
To reproduce: public Form1() { InitializeComponent(); this.radPropertyGrid1.SelectedObject = this; this.radPropertyGrid1.ContextMenuOpening += radPropertyGrid1_ContextMenuOpening; } private void radPropertyGrid1_ContextMenuOpening(object sender, Telerik.WinControls.UI.PropertyGridContextMenuOpeningEventArgs e) { foreach (RadItem item in e.Menu.Items) { if (item.Text == "Sort") { item.Visibility = ElementVisibility.Collapsed; item.PropertyChanged += item_PropertyChanged; } } } Workaround: private void radPropertyGrid1_ContextMenuOpening(object sender, Telerik.WinControls.UI.PropertyGridContextMenuOpeningEventArgs e) { RadItem item = null; for (int i = 0; i < e.Menu.Items.Count; i++) { item = e.Menu.Items[i]; if (item.Text=="Sort") { e.Menu.Items.Remove(item); } } }
To reproduce: Use the following code snippet and perform the step illustrating on the attached gif file. Note that this undesired behavior appears randomly. Partial Public Class Form1 Inherits Telerik.WinControls.UI.RadForm Public Sub New() InitializeComponent() radPropertyGrid1.PropertySort = Windows.Forms.PropertySort.Categorized radPropertyGrid1.SortOrder = Windows.Forms.SortOrder.None Dim metaDocItem As New PropertyStoreItem(GetType(String), "Document ID", "16.0", "Document ID Number", "Meta Data", True) Dim fileInfoItem As New PropertyStoreItem(GetType(FileInfo), "File Info", New FileInfo("sample file path", "file name path"), _ "", "Meta Data", True) fileInfoItem.Attributes.Add(New TypeConverterAttribute(GetType(MyDataConverter))) Dim stringItem As New PropertyStoreItem(GetType(String), "String", "telerik", "Property storing a string value", "Meta Data", True) Dim dockItem As New PropertyStoreItem(GetType(DockStyle), "Dock", DockStyle.Top, "Property containing DockStyle value", "Meta Data", True) Dim store As New RadPropertyStore store.Add(metaDocItem) store.Add(fileInfoItem) store.Add(stringItem) store.Add(dockItem) Me.RadPropertyGrid1.SelectedObject = store End Sub End Class Public Class FileInfo Private _filePath As String Private _fileName As String Public Sub New(filePath As String, fileName As String) Me._filePath = filePath Me._fileName = fileName End Sub Public ReadOnly Property FilePath() As String Get Return _filePath End Get End Property Public ReadOnly Property FileName() As String Get Return _fileName End Get End Property End Class Public Class MyDataConverter Inherits ExpandableObjectConverter Public Overrides Function CanConvertTo(context As ITypeDescriptorContext, destinationType As Type) As Boolean If destinationType = GetType(String) Then Return True End If Return MyBase.CanConvertTo(context, destinationType) End Function Public Overrides Function ConvertTo(context As ITypeDescriptorContext, culture As System.Globalization.CultureInfo, _ value As Object, destinationType As Type) As Object If destinationType <> GetType(String) Then Return MyBase.ConvertTo(context, culture, value, destinationType) End If Return String.Empty End Function End Class Workaround: add a RadSortOrderAttribute to each PropertyStoreItem and leave the default SortOrder = Windows.Forms.SortOrder.Ascending
To reproduce: Open VisualStyleBuilder and navigate to RadGanttView -> RadGanttViewElement and try to edit the Value of the BackgroundImageLayout and ImageLayout properties. Workaround: Edit the value manually, as a string