propertygrid

Expand custom object in property grid without any modifications to the class?

最后都变了- 提交于 2019-12-24 00:46:57
问题 By default, custom objects are grayed out, and not expandable: I know it's possible to make them expandable using ExpandableObjectConverter, but that requires extending the original class. What if I cannot modify the original class? Is there a generic approach of handling custom object expansion inside a property grid? 回答1: You can dynamically add the TypeConverterAttribute for the ExpandableObjectConverter at runtime, using something like the following (VB.NET). Dim attr = New

Adding Editor / EditorAttribute at Run-time (Dynamically) to an Object's Property

纵饮孤独 提交于 2019-12-23 12:37:34
问题 How to add the EditorAttribute (Editor) to an object's property at run-time? I have My.Settings.ExcludeFiles , which is created by the settings designer as Public Property ExcludedFiles() As Global.System.Collections.Specialized.StringCollection . When editing ExcludedFiles via a property grid, the "String Collection Editor" generates a "Constructor on type 'System.String' not found" run-time exception. I cannot change the attributes of the ExcludeFiles property because they will be

PropertyGrid and Dynamic Types of Objects

。_饼干妹妹 提交于 2019-12-23 11:47:35
问题 I'm writing a GUI application where I need to enable editing properties of arbitrary objects (their types are only known at run-time). I've decided to use the PropertyGrid control to enable this functionality. I created the following class: [TypeConverter(typeof(ExpandableObjectConverter))] [DefaultPropertyAttribute("Value")] public class Wrapper { public Wrapper(object val) { m_Value = val; } private object m_Value; [NotifyParentPropertyAttribute(true)] [TypeConverter(typeof

Property grid item and DoubleClick

天涯浪子 提交于 2019-12-23 09:33:26
问题 I'm using PropertyGrid control for editing some objects in my application. I'm using custom TypeConverters and TypeEditors for better user interface. I have problem with custom TypeConverter for boolean properties. If I have this class: public class MyClass { public string Name { get; set; } [System.ComponentModel.TypeConverter( typeof( BoolTypeConverter ) )] public bool Flag { get; set; } } and I create instance and set it as SelectedObject in PropertyGrid - all is fine until the user

C# UITypeEditor with Parameter

时间秒杀一切 提交于 2019-12-22 19:01:33
问题 I have created a custom UITypeEditor which launches a form (StringSelector) to display a list of strings which the user choses from. The problem is that this form needs to know what StringManager to use (stringmanage is simply a class which contains all the strings allowed in a List). When I created this form I was passing in the StringManager as a parameter in the Constructor, but I cannot work out how i can do this with the UITypeEditor. Below is my current code which uses a constructor

How to get a PropertyGrid's cell value (c#)?

十年热恋 提交于 2019-12-22 11:12:29
问题 How can I get property grid items and item's value in c# ? for example : Name : Ali LastName : Ahmadi (Name and LastName are 2 properties of propertygrid) 回答1: PropertyGrid is just a view over the component-model representation of an object. Rather than look at the grid, I would say: look at the component-model, for example: var props = TypeDescriptor.GetProperties(obj); foreach(var prop in props) { string name = prop.DisplayName; if(string.IsNullOrEmpty(name)) name = prop.Name; Console

Displaying a Collection in a PropertyGrid Control

[亡魂溺海] 提交于 2019-12-22 08:47:40
问题 I have an array of objects containing pairs of string labels and values, how would I put them all in a single property grid? public class stringVariable { public String name; public String defaultValue; public String value; }; public List<stringVariable> variables = new List<stringVariable>(); 回答1: Adding an array of objects to a property grid is pretty well covered in a number of tutorials. This should be what you're looking for. 回答2: Its not entirely straight forward, but possible. You need

How to use the property grid in a form to edit any Type

霸气de小男生 提交于 2019-12-21 20:25:11
问题 I have an App where I'd like to be able to edit any type (font, colour, point etc.) at run time and use any of the .Net default type editors. (e.g., font/ colour picker). Rather than re-invent the wheel, I decided to use the property grid control. If I pass an object of, say font, to the grid, it lists all the fields separately, with no option to open the font picker. Therefore, I created this generic wrapper class: Private Class Wrapper(Of T) Private _Value As T Public Property Value() As T

Limitations of using .NET 2.0 (Windows Forms) controls in WPF?

与世无争的帅哥 提交于 2019-12-21 17:40:13
问题 I want to start a new application on WPF. The new User interface in WPF needs DataGridView control and PropertyGrid Control. But it looks like that these two controls won't exist in WPF and I want to host these two controls using WindowsFormsHost . However, if I do that, is there any limitation anybody forsee with this approach? 回答1: The main limitation is that you loose all the powerful features of WPF: Data binding , ControlTemplates and DataTemplates , Infinite sizing, Zooms/Rotations,

Using Xceed PropertyGrid

折月煮酒 提交于 2019-12-21 09:18:40
问题 I am a beginner at C#/WPF and am trying to use the Xceed PropertyGrid. On their site they show an example: <xctk:PropertyGrid x:Name="_propertyGrid" Width="450" Margin="10" AutoGenerateProperties="False"> <!-- Only the following properties will be displayed in the PropertyGrid --> <xctk:PropertyGrid.PropertyDefinitions> <xctk:PropertyDefinition Name="FirstName" /> <xctk:PropertyDefinition Name="FavoriteColor" /> <xctk:PropertyDefinition Name="PetNames" /> </xctk:PropertyGrid