propertygrid

Can we change the text/background color of an individual property in PropertyGrid

廉价感情. 提交于 2019-11-29 11:52:13
I have a .NET PropertyGrid control which displays properties of some class. I want to change the color or font or background color(it doesn't matter just that they look different from the other displayed properties) of some property. I can do with writing custom editor but I was wondering: If an easier method exists? If I use custom editor then how do i change the editor of built-in types like bool, int etc? No can do. The class that determines how an item is drawn is PropertyGridView. The source code is interesting, it almost made it: private /*protected virtual*/ PropertyGridView

Properties generated at runtime (PropertyGrid.SelectedObject)

落花浮王杯 提交于 2019-11-29 08:17:26
Ok, this is a tough one. Introduction: My idea is to attach an instanciated QueryBuilder class which I wrote, to a PropertyGrid. The QueryBuilder class now contains a couple of fields, which are hardcoded like in the example below. Thus allowing a user to specify, which fields should be used in a query in what way (sorted, grouped, and so on). After the user having specified all the settings to these properties (by code or via the PropertyGrid GUI), the QueryBuilder is able to produce a query. Everything is working fine like that. Pseudo code: class QueryBuilder { public QBField name {get; set

Windows 10 Creators Update changes the style of PropertyGrid control

为君一笑 提交于 2019-11-29 07:06:06
I just upgraded some systems to Windows 10 Creators Update and I noticed that the windows forms PropertyGrid control changed its default visual style for headers and bar margins to dark gray, like so: And as mostly happens with unexpected visual changes, users are not happy. Is there a way to revert back to the old default or maybe override the default style? There's a bug in PropertyGrid: The property PropertyGrid.LineColor has a DefaultValue attribute Set to SystemColors.InactiveBorder . But the internal field lineColor is initialized with SystemColors.ControlDark . This is bad, because the

Property Grid Number formatting

為{幸葍}努か 提交于 2019-11-29 06:46:40
Is it possible to format numerical properties displayed in PropertyGrid of winforms? class MyData { public int MyProp {get; set;} } And I want it to be displayed in the grid as 1.000.000 for example. Are there some attributes for this? You should implement custom type converter for your integer property: class MyData { [TypeConverter(typeof(CustomNumberTypeConverter))] public int MyProp { get; set; } } PropertyGrid uses TypeConverter to convert your object type (integer in this case) to string, which it uses to display object value in the grid. During editing, the TypeConverter converts back

Make a property visible in DataGridView but NOT in PropertyGrid?

孤人 提交于 2019-11-29 04:40:49
Let's say I have a property which I want shown in a DataGridView, but not when the same object is shown in a PropertyGrid. I know I can use [Browsable(false)] , but that hides it in both views. I can also do a gridView.Columns["blah"].Visible = false; , but this is the opposite of what I want, as it hides in the DataGridView but not in PropertyGrid. Is there some way to do the reverse? (Short of creating a whole new DataTable just to hold the same data minus one field, and rebinding everything to that instead - that's really a kludge way to do things.) Alternatively, I could live with a

Is there a Property Dialog control that i can use in my WPF App?

微笑、不失礼 提交于 2019-11-29 03:08:32
问题 I'm building an application using WPF that will be a designer of sorts, meaning, a user can drag and drop custom UI elements into a canvas and be able to configure their behavior via properties. (Think of this like a domain specific PowerPoint. You can add elements to the presentation, configure the elements' properties and then eventually you can run the "slideshow" and those elements will behave according to their properties) So in my app, what is the best way of showing and configuring an

Using a Dictionary in a propertygrid

百般思念 提交于 2019-11-29 01:47:55
I'd like to edit a list of key value(string, string) items using a propertygrid. When I use a Dictionary<string,string> as type the propertygrid will show a GUI, but it does not seem "enabled", ie. I can't add any items. Is the Dictionary object supported, or is there any other object with which I could solve this problem? Iain I have done it following this code in the past: class DictionaryPropertyGridAdapter : ICustomTypeDescriptor { IDictionary _dictionary; public DictionaryPropertyGridAdapter(IDictionary d) { _dictionary = d; } public string GetComponentName() { return TypeDescriptor

Multi-line string in a PropertyGrid

淺唱寂寞╮ 提交于 2019-11-29 01:01:39
Is there a built-in editor for a multi-line string in a PropertyGrid . I found that System.Design.dll has System.ComponentModel.Design.MultilineStringEditor which can be used as follows: public class Stuff { [Editor(typeof(MultilineStringEditor), typeof(UITypeEditor))] public string MultiLineProperty { get; set; } } No, you will need to create what's called a modal UI type editor. You'll need to create a class that inherits from UITypeEditor. This is basically a form that gets shown when you click on the ellipsis button on the right side of the property you are editing. The only drawback I

Custom, Complicated, Dynamic Reflection Solution - C#

主宰稳场 提交于 2019-11-29 01:00:08
问题 I have many custom classes that I am using that I will explain and post examples of. After Explaining what they all do I will try to clearly describe the conditions under which my bug is happening. First, I am using a PropertyGrid to display the properties of several different types of objects. Because the default binding of the PropertyGrid was not what as descriptive as I wanted it to be, I created a few custom classes that I will refer to as "Display" classes. These Display classes are

How can I force the PropertyGrid to show a custom dialog for a specific property?

徘徊边缘 提交于 2019-11-29 00:52:59
问题 I have a class with a string property, having both a getter and a setter, that is often so long that the PropertyGrid truncates the string value. How can I force the PropertyGrid to show an ellipsis and then launch a dialog that contains a multiline textbox for easy editing of the property? I know I probably have to set some kind of attribute on the property, but what attribute and how? Does my dialog have to implement some special designer interface? Update: This is probably the answer to my