propertygrid

Programmatically Hide Field in PropertyGrid

穿精又带淫゛_ 提交于 2019-11-27 06:24:08
问题 Using <System.ComponentModel.TypeConverter(GetType(System.ComponentModel.ExpandableObjectConverter))> _ on the declaration of a class (which is a property of another class) that consists of a number properties. I load an instance of this class with simply ... PropertyGrid1.SelectedObject = oColumn Obviously I don't want to manually build the propertygrid in code, I know how to do that. But here's the problem. Depending on the value of a property, certain other properties should not be visible

Remove C# attribute of a property dynamically

白昼怎懂夜的黑 提交于 2019-11-27 04:40:26
I have a class with a set of properties As given below. class ContactInfo { [ReadOnly(true)] [Category("Contact Info")] public string Mobile { get; set; } [Category("Contact Info")] public string Name{ get; set; } } The objects of this class is being assigned to a property grid, so that the users can update an existing contact . you can see that Mobile is marked as ReadOnly. But, when I want to add an entirely new Contact , I would want the users to be able to edit the contact Mobile also. For that I need to remove the Readonly property dynamically from the Type, before assigning the object to

How can I use a WinForms PropertyGrid to edit a list of strings?

爱⌒轻易说出口 提交于 2019-11-27 04:27:32
问题 In my application I have a property grid to allow users to change settings. This works fine for strings and other value properties, but what I need now is a list of strings that can be edited by users. The problem is that if I have MyPropertyGrid.SelectedObject = new { Test = new List<string>() }; in my code and the user attempts to edit the Test property, when they click on the Add button, the following error occurs: Constructor on type 'System.String' not found This makes sense as strings

How to create custom PropertyGrid editor item which opens a form?

女生的网名这么多〃 提交于 2019-11-27 03:27:32
I have a List<> (my custom class). I want to display a specific item in this list in a box on the PropertyGrid control. At the end of the box I would like the [...] button. When clicked, it would open up a form which, among other things, would allow them to pick one of the items from the List. When closed, the PropertyGrid would be updated to reflect the selected value. Any help appreciated. You need to implement a modal UITypeEditor , using the IWindowsFormsEditorService service to display it: using System.ComponentModel; using System.Drawing.Design; using System.Windows.Forms; using System

Show detailed Folder Browser from a PropertyGrid

我怕爱的太早我们不能终老 提交于 2019-11-27 01:08:11
问题 Please note it is not a duplicate question. How to show a detailed FolderBrowser as in the image below from a PropertyGrid (from the field/property which has ellipses ...) Using [EditorAttribute(typeof(System.Windows.Forms.Design.FileNameEditor), typeof(System.Drawing.Design.UITypeEditor))] [EditorAttribute(typeof(System.Windows.Forms.Design.FolderNameEditor), typeof(System.Drawing.Design.UITypeEditor))] We get the minimalistic folder browser 回答1: Here is a custom UITypeEditor that allows you

display list of custom objects as a drop-down in the PropertiesGrid

南笙酒味 提交于 2019-11-26 18:24:18
问题 I want to take an object, let's say this object: public class BenchmarkList { public string ListName { get; set; } public IList<Benchmark> Benchmarks { get; set; } } and have that object display its ListName as the "name" part of the PropertiesGrid ("Benchmark" would be good), and for the "value" part of the PropertyGrid, to have a drop-down list of the IList<> of Benchmarks: here is the Benchmark object public class Benchmark { public int ID {get; set;} public string Name { get; set; }

Remove C# attribute of a property dynamically

我怕爱的太早我们不能终老 提交于 2019-11-26 11:18:15
问题 I have a class with a set of properties As given below. class ContactInfo { [ReadOnly(true)] [Category(\"Contact Info\")] public string Mobile { get; set; } [Category(\"Contact Info\")] public string Name{ get; set; } } The objects of this class is being assigned to a property grid, so that the users can update an existing contact . you can see that Mobile is marked as ReadOnly. But, when I want to add an entirely new Contact , I would want the users to be able to edit the contact Mobile also

How to create custom PropertyGrid editor item which opens a form?

落花浮王杯 提交于 2019-11-26 10:29:14
问题 I have a List<> (my custom class). I want to display a specific item in this list in a box on the PropertyGrid control. At the end of the box I would like the [...] button. When clicked, it would open up a form which, among other things, would allow them to pick one of the items from the List. When closed, the PropertyGrid would be updated to reflect the selected value. Any help appreciated. 回答1: You need to implement a modal UITypeEditor , using the IWindowsFormsEditorService service to

How to add property-level Attribute to the TypeDescriptor at runtime?

本秂侑毒 提交于 2019-11-26 09:44:36
问题 I want to add some custom PropertyGrid-centric Attributes to the object\'s properties, to provide richer editing, hide some values and group them in categories, because that class I\'m working with doesn\'t provide such functionality and I can\'t do anything about it. Really, it\'s for MS\'s Application Settings that generates code, so you can\'t extend it in any way property-wise. See my other question: Runtime AppSettings.settings editor dialog 回答1: Unlike others have suggested, it's quite