propertygrid

Change DisplayName attribute for a property

南笙酒味 提交于 2019-12-11 08:25:10
问题 I am looking for a way to change the value of the DisplayName attribute of a property at run-time. Is this even possible in Windows Forms? 回答1: Create your own TypeDescriptionProvider for your class, and assign it at runtime to single object (or entire class) using TypeDescriptor. Also look into GetTypeDescriptor and GetProperties, and finally AttributeArray. In general creating your own type descriptor is not so hard, but you need to read msdn carefully and do a lot of tries. 来源: https:/

WPF Property Grid

北城以北 提交于 2019-12-11 06:19:22
问题 Is there a way, when binding to a Dependency Object class, to hide class properties? I mean those "Dispatcher", "DependencyObjectType" and "IsSealed"? using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.ComponentModel; using System.Windows; namespace WPGDemoApp { public class SampleObject : DependencyObject { readonly static DependencyProperty IdProperty = DependencyProperty.Register("ID", typeof(int), typeof(SampleObject)); public int ID { get {

Make all properties with specific Category name invisible in PropertyGrid in c# Winforms at Runtime based on some condition

放肆的年华 提交于 2019-12-11 06:02:17
问题 I have a property Grid in my application which shows the properties of a selected control at run time. Recently there was a requirement to add some extra properties to the already existing controls. To accommodate this a new category was introduced under which the newer properties were added. Now I am looking for a mechanism to hide these newly added properties at run time based on a runtime condition in the application. But I don’t have a proper solution for this. Newly added code: [ReadOnly

How to create a PropertyGrid editor that limits a string to n characters

好久不见. 提交于 2019-12-11 05:06:29
问题 I have attempted to create my own UITypeEditor but the EditValue method never gets called public class BoundedTextEditor : UITypeEditor { public override System.Drawing.Design.UITypeEditorEditStyle GetEditStyle(System.ComponentModel.ITypeDescriptorContext context) { return UITypeEditorEditStyle.None; } public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value) { if (value.GetType() != typeof(string)) return value; var

How can you programmatically order categories in the Xceed PropertyGrid?

对着背影说爱祢 提交于 2019-12-11 04:49:09
问题 As shown in the example here, what I'm trying to achieve is ordering categories in the Xceed PropertyGrid control. As that example shows (copied here for reference), you can specify this information at compile-time by adding attributes to the class, like so... [CategoryOrder("General", 1)] [CategoryOrder("Advanced", 2)] [CategoryOrder("Other", 3)] public class MyClass { [Category("General")] public string Property1 { get; set; } [Category("Advanced")] public int Property2 { get; set; }

Hide ellipsis (…) button of expandable property like “…” button of font property in the property grid

一个人想着一个人 提交于 2019-12-11 04:39:23
问题 I've added a new property to my custom control as expandable property like font property in Property Grid. After using from my custom control in a Windows Forms Application project, I see an ellipsis (…) button like "…" button of font property in Property Grid. (For more information, please see the following picture.) Now, I want to hide the ellipsis (…) button for my new expandable property. Expandable property codes are: [DisplayName("Floors Information")] [Description("Floors

How to make a Stripped Down PropertyGrid

蹲街弑〆低调 提交于 2019-12-11 03:57:03
问题 I'm building an app where I show data in a tree view, and when a user double-clicks on an element in the tree view, the node they clicked on is replaced with an editable version of the node. The way different nodes are edited varies greatly, so using the built-in ability to change the text of the node is not acceptable. I instead need to use a property grid and define [Editor] attributes. The only problem is that the property grid shows two columns: One with the name of the property, and the

Looking for a way to dynamically change field names in PropertyGrid

為{幸葍}努か 提交于 2019-12-11 03:07:41
问题 I've got COM object attached to property grid. Type typeObj = Type.GetTypeFromProgID(progIdService); var obj = Activator.CreateInstance(typeObj); propertyGrid1.SelectedObject = obj; Now I need some way to translate object fields into my language using some translator. I was trying to use wrapper around object but with COM object I have no PropertyInfo , I have only PropertyDescription so I'm still looking for all the possible variants of doing it. 回答1: What you could do is reuse the

my.settings and descriptions? And getting them into a propertygrid?

送分小仙女□ 提交于 2019-12-11 02:45:48
问题 I recently learned of the propertygrid object usage with the my.settings object for a project. I like this very much and I was wondering if there is a way to include descriptions with my settings so that they will be included in the propertygrid in the lower description panel? I found a couple of old (2003) codeproj articles that covers this but it requires a lot of custom work and was hoping that there has been an easier method to come around. 回答1: This is very simple to do and doesn't

Propertygrid UIEditor disabling value editing through Keyboard

谁说胖子不能爱 提交于 2019-12-11 02:04:38
问题 I have a propertygrid that uses UITypeEditor to display a Listbox and select a item. This item gets returned on the proertygrid on selection. But how do I disable editing of the selected item directly, readonly option prevents it from getting edited. Let's say I'm changing a Property Country from another form which displays a list of countries in a listbox. When I select 'Algeria' and press OK, 'Algeria' is displayed across Country, but I can directly edit Algeria to any other value,