Currently editors not shown as dialog do not work as the RadPropertyGrid editor is closed when focus is transferred to the dialog form.
Workaround use the attached custom theme: http://docs.telerik.com/devtools/winforms/themes/using-custom-themes
To reproduce: subscribe to the RadPropertyGrid.PropertyValidating event and apply ErrorMessage in some cases. If the validation fails, the error indicator is not visible in Windows8, VisualStudio2012Dark, Aqua. However, the error message is displayed as expected. Workaround: assign an image for the ErrorIndicator private void radPropertyGrid1_ItemFormatting(object sender, PropertyGridItemFormattingEventArgs e) { PropertyGridItemElement itemElement = e.VisualElement as PropertyGridItemElement; if (itemElement != null) { ((PropertyGridTextElement)itemElement.TextElement).ErrorIndicator.Image = Properties.Resources.error; } }
Please refer to the attached sample project.
Please refer to the attached gif file demonstrating how to reproduce the error with the Demo application. Workaround: change the DropDownStyle property to DropDownList: private void radPropertyGrid1_EditorInitialized(object sender, PropertyGridItemEditorInitializedEventArgs e) { PropertyGridDropDownListEditor editor = e.Editor as PropertyGridDropDownListEditor; if (editor!=null) { BaseDropDownListEditorElement editorElement = editor.EditorElement as BaseDropDownListEditorElement; editorElement.DropDownStyle = Telerik.WinControls.RadDropDownStyle.DropDownList; } }
Use attached project to reproduce! This works fine in 2016.2.608. Workaround: Use singe RadPropertyStore object instead of an array.
To reproduce: public Form1() { InitializeComponent(); this.radPropertyGrid1.Size = new System.Drawing.Size(272, 135); PropertyStoreItem intItem = new PropertyStoreItem(typeof(int), "Integer", 1); PropertyStoreItem showTrend = new PropertyStoreItem(typeof(bool), "ShowTrend", 0); PropertyStoreItem trendItem1 = new PropertyStoreItem(typeof(int), "TrendTypes", 0); // Case of Re-loading the previously Saved Trend Type PropertyStoreItem floatItem = new PropertyStoreItem(typeof(float), "Float", 1f, "Property storing a floating point value."); PropertyStoreItem stringItem = new PropertyStoreItem(typeof(string), "String", "Telerik", "Property storing a string value", "Telerik"); PropertyStoreItem dockItem = new PropertyStoreItem(typeof(DockStyle), "Dock", DockStyle.Top, "Property containing DockStyle value", "Layout", false); RadPropertyStore store = new RadPropertyStore(); store.Add(intItem); store.Add(showTrend); store.Add(trendItem1); store.Add(floatItem); store.Add(stringItem); store.Add(dockItem); this.radPropertyGrid1.SelectedObject = store; radPropertyGrid1.Items["TrendTypes"].Visible = false; this.radPropertyGrid1.PropertyValueChanged += radPropertyGrid1_ValueChanged; } private void radPropertyGrid1_ValueChanged(object sender, PropertyGridItemValueChangedEventArgs e) { PropertyGridItem current = (PropertyGridItem)e.Item; if (current.Name == "ShowTrend") { bool val = Convert.ToBoolean(current.Value); radPropertyGrid1.Items["TrendTypes"].Visible = val; } } - There is no scrollbar when the item is shown. Workaround: radPropertyGrid1.PropertyGridElement.PropertyTableElement.Update(PropertyGridTableElement.UpdateActions.ExpandedChanged);
To reproduce: please refer to the attached gif file. The error is not reproduced each time with the Demo application. Sometimes an unhandled exception dialog appears and sometimes the application becomes unresponsive and you can not close the application with upper right X, the options to the right does not respond, you can not change demo using the list on the left. Selecting "Settings" in Property Grid section and then clicking on a boolean property (left column), scrolling using the mouse wheel, then selecting another property (with PropertyGridDropDownListEditor) or clicking around in the application (even outside of the property grid form). Workaround: this.radPropertyGrid1.EditorRequired += radPropertyGrid1_EditorRequired; private void radPropertyGrid1_EditorRequired(object sender, PropertyGridEditorRequiredEventArgs e) { if (e.EditorType == typeof(PropertyGridDropDownListEditor)) { e.Editor = new CustomPropertyGridDropDownListEditor(); } } public class CustomPropertyGridDropDownListEditor : PropertyGridDropDownListEditor { public override object Value { get { PropertyGridItemElement element = this.OwnerElement as PropertyGridItemElement; PropertyGridItem item = element.Data as PropertyGridItem; if (item == null) { return null; } return base.Value; } set { base.Value = value; } } }
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); }
Generic collections are used by entity framework to contain child objects. UPDATE: RadPropertygrid uses the standard System.ComponentMode.Design.CollectionEditor when editing collections. The editor requirements are that the collection being edited implements the IList interface and that it has an indexer (Item in VB.NET) property. Entity Framework generates an ICollection<T> property which holds a HasSet<T> object. This does not fit both requirements of the editor and prevents it from working correctly.
Developers should be able to validate user input in the RadPropertyStore items. UPDATE: Currently we have decided to stick with the current implementation where all the validation is done through the PropertyValidating/ed events.
To reproduce: Add a RadPropertyGrid to a form. Use the following code: this.radPropertyGrid1.SortOrder = System.Windows.Forms.SortOrder.Ascending; this.radPropertyGrid1.PropertySort = System.Windows.Forms.PropertySort.Categorized; As a workaround you can manually scroll to the top before performing a filtering operation: public class MyPropertyGrid : RadPropertyGrid { protected override PropertyGridElement CreatePropertyGridElement() { return new MyPropertyGridElement(); } } public class MyPropertyGridElement : PropertyGridElement { protected override PropertyGridToolbarElement CreateToolbarElement() { return new MyPropertyGridToolbarElement(); } protected override Type ThemeEffectiveType { get { return typeof(PropertyGridElement); } } } public class MyPropertyGridToolbarElement : PropertyGridToolbarElement { protected override void ExecuteSearch() { this.PropertyGridElement.PropertyTableElement.Scroller.Scrollbar.Value = 0; base.ExecuteSearch(); } }
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); } }
Until the new feature is officially released please use the implementation in the attached project.
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
To reproduce: PropertyStoreItem prop1 = new PropertyStoreItem(typeof(DateTime), "Date", DateTime.Now); PropertyStoreItem prop2 = new PropertyStoreItem(typeof(Nullable<DateTime>), "NullableDate", DateTime.Now); PropertyStoreItem prop3 = new PropertyStoreItem(typeof(DateTime?), "Date?", DateTime.Now); RadPropertyStore store = new RadPropertyStore(); store.Add(prop1); store.Add(prop2); store.Add(prop3); this.radPropertyGrid1.SelectedObject = store; Open the editor for one of the properties and press the Clear button in the PropertyGridDateTimeEditor's popup. The value is cleared, but the PropertyValueButtonElement is not displayed. Workaround: specify the initial value as default value for the property: public Form1() { InitializeComponent(); DateTime initialValue = DateTime.Now; PropertyStoreItem prop1 = new PropertyStoreItem(typeof(DateTime), "Date", initialValue); prop1.Attributes.Add(new DefaultValueAttribute(initialValue)); PropertyStoreItem prop2 = new PropertyStoreItem(typeof(Nullable<DateTime>), "NullableDate", initialValue); prop2.Attributes.Add(new DefaultValueAttribute(initialValue)); PropertyStoreItem prop3 = new PropertyStoreItem(typeof(DateTime?), "Date?", initialValue); prop3.Attributes.Add(new DefaultValueAttribute(initialValue)); RadPropertyStore store = new RadPropertyStore(); store.Add(prop1); store.Add(prop2); store.Add(prop3); this.radPropertyGrid1.SelectedObject = store; }