Hi, For the Microsoft PropertyGrid, your control must implement the ICustomTypeDescriptor interface or be associated with a TypeDescriptionProvider (>= .net 2.0). You will find the resources here: http://www.propertygridresourcelist.com/index.php/resources/tag/icustomtypedescriptor/. Basically the GetProperties method will return a PropertyDescriptor only if it comes from your class and remove it if it comes from an ancestor. Best regards, Nicolas Cadilhac @ VisualHint Smart PropertyGrid.Net Microsoft PropertyGrid Resource List Free PropertyGrid for MFC Smart FieldPackEditor.Net / DateTimePicker
visualhint
Posts
-
class object properties -
PropertyGrid questionsHi, The MS PropertyGrid has not been designed to do that but you can still call the SelectedGridItem property to get the selected property, and then Parent property of the returned GridItem until GridItemType equals Root. Then, you can recursively parse the grid with the GridItems property of the GridItem class. After that, the Value and PropertyDescriptor properties will help you compare the actual value with the default one. I hope this helps. Best regards, Nicolas Cadilhac @ VisualHint Smart PropertyGrid.Net Microsoft PropertyGrid Resource List Free PropertyGrid for MFC Smart FieldPackEditor.Net / DateTimePicker
-
CollectionBase to PropertyGridHi, If you want to see the items of the collection as child properties in the grid, you need to assign your collection property a TypeConverter that will publish the items as properties (override GetPropertiesSupported and GetProperties). Best regards, Nicolas Cadilhac @ VisualHint Smart PropertyGrid.Net Microsoft PropertyGrid Resource List Free PropertyGrid for MFC Smart FieldPackEditor.Net / DateTimePicker
-
How do I create a PropertyGrid with dynamic Properties?Hi, The PropertyGrid is a complex component. If you want to use it, I recommend you to dig in the various docs, howtos, blog posts, etc. The Microsoft PropertyGrid is not very flexible but it can be powerful when you know all the internals of the ComponentModel stuff. A good starting point is the "Microsoft PropertyGrid Resource List" (see signature). If you still can't make it work, ask some detailed questions, one per particular issue (yours is a bit vague). About your last sentence, use the DescriptionAttribute and DefaultValueAttribute. If you need them to be dynamic, you will need to publish your properties with the help of a custom type descriptor and custom property descriptors. At last if a 3rd party component is an option for you, Smart PropertyGrid.Net is a time saver to build dynamic contents. Best regards, Nicolas Cadilhac @ VisualHint Smart PropertyGrid.Net Microsoft PropertyGrid Resource List Free PropertyGrid for MFC Smart FieldPackEditor.Net / DateTimePicker
-
Dynamically add a property item to Property GridRajan, The Microsoft PropertyGrid does not allow you to add a new property to the grid in a few lines of code. Instead you must use various techniques to publish dynamically a set of PropertyDescriptors. The most famous article to do that is: http://www.codeproject.com/KB/miscctrl/bending_property.aspx. If a third party component is an option, only Smart PropertyGrid enables you to call properties like AppendProperty. Best regards, Nicolas Cadilhac @ VisualHint Smart PropertyGrid.Net Microsoft PropertyGrid Resource List Free PropertyGrid for MFC Smart FieldPackEditor.Net / DateTimePicker
-
Add TrackBar to PropertyGrid - C#Hi, You are correct. The Microsoft PropertyGrid only allows a simple textbox, a textbox + button, or a textbox + dropdown button as inplace editors. Therefore you have 2 solutions: 1. Either host your trackbar in the dropdown window appearing when you click the dropdown button. You will need a UITypeEditor for that. 2. Or use a third party PropertyGrid like Smart PropertyGrid which allows many more types of inplace controls, the trackbar being one of them. Best regards, Nicolas Cadilhac @ VisualHint Smart PropertyGrid.Net Microsoft PropertyGrid Resource List Free PropertyGrid for MFC Smart FieldPackEditor.Net / DateTimePicker
-
PropertyGridHello, if a commercial product is an option for you, only Smart PropertyGrid will give you the flexibility of choosing a disabled mode for the PropertyGrid. By descending order of "disabled" importance: 1. It can be completely disabled (nothing is actionable, not even the scrollbar). 2. It can be completely disabled (nothing is actionable except the +/- signs and it is scrollable). 3. It can be disabled with the properties still selectable and scrollable. 4. It can minimally be disabled with the property values selectable so that you can copy their value. The PropertyGrid doesn't handle a direct way to disable everything. You would have to set a hardcoded Readonly attribute on your properties or to publish dynamically a Readonly attribute for your properties with a TypeConverter or Type Descriptor... not very easy for a simple requirement... Best regards, Nicolas Cadilhac @ VisualHint Smart PropertyGrid.Net Microsoft PropertyGrid Resource List Free PropertyGrid for MFC Smart FieldPackEditor.Net / DateTimePicker
-
DateTimePicker UpDown default to change secondsHello Glenn, There is no way to programmatically change the currently selected field in a Microsoft DateTimePicker. There is no notion of default field either. The first time the user goes on this dtp, the minutes field is selected. If he leaves the field after selecting the seconds field, when coming back to the dtp, the seconds will be selected and the updown field will act on this field. Best regards, Nicolas Cadilhac @ VisualHint Smart FieldPackEditor.Net / DateTimePicker Smart PropertyGrid.Net Microsoft PropertyGrid Resource List Free PropertyGrid for MFC
-
Question about PropertyGridHi, You must explicitely tell the PropertyGrid to show subproperties. To do that, the easiest way is to assign the ExpandableObjectConverter to your Parent and Child classes, like this:
[TypeConverter(typeof(ExpandableObjectConverter ))]
class Parent
{
private Child child = new Child();
public Child ChildInstance
{
get { return child; }
set { child = value; }
}
}[TypeConverter(typeof(ExpandableObjectConverter ))]
class Child
{
private string text = "Hello Child";
public string Text
{
get { return text; }
set { text = value; }
}
}Best regards, Nicolas Cadilhac @ VisualHint Smart PropertyGrid.Net Microsoft PropertyGrid Resource List Free PropertyGrid for MFC Smart FieldPackEditor.Net / DateTimePicker
-
properties sort orderhi, I would create a TypeConverter for your employee class (derived from ExpandableObjectConverter). Its GetProperties method would then return something like: return TypeDescriptor.GetProperties(typeof(Employee), attributes).Sort(new string[] { "ID" }); The GetPropertiesSupported method must return true too. If you need to specify the order after "ID", pass more strings in the array. Best regards, Nicolas Cadilhac @ VisualHint Smart PropertyGrid.Net Microsoft PropertyGrid Resource List Free PropertyGrid for MFC Smart FieldPackEditor.Net / DateTimePicker
-
How do I create a ProperyGrid subcategory?Hi David, As Tom explained, with the Microsoft PropertyGrid, you can't create subcategories. You can only create kind of container-like properties that you publish with a custom type descriptor. If a commercial product is an option for you, only Smart PropertyGrid.Net is able to create true subcategories. Best regards, Nicolas Cadilhac @ VisualHint Smart PropertyGrid.Net Microsoft PropertyGrid Resource List Free PropertyGrid for MFC Smart FieldPackEditor.Net / DateTimePicker
-
Why i am getting MessageBox twiceHi, To investigate your issue, I tried your TypeConverter with my product, Smart PropertyGrid.Net. I also got the form twice and this is for this reason: the grid reacts to validation with the Enter key and also to the loss of focus. When Enter is pressed, your ConvertFrom method is called and the dialog box is displayed. Because the grid does not expect any UI to be shown at that moment, it also reacts to the loss of focus and tries to validate again the new value. Therefore, the ConvertFrom is called again and the form is displayed a second time. It won't happen indefinitely since at this time, the focus has been definitely lost. I guess that the MS PropertyGrid acts in the same way. By showing a message box, you are going against the way it's supposed to work. No UI should be displayed by a TypeConverter whose goal is just to convert. If it fails to convert a value, it's supposed to throw an exception and the grid will show it. Smart PropertyGrid has of course more flexible mechanisms to validate and show errors. Anyway, in SPG, I was able to stop this problem by defining a static bool isInsideConvertFrom. This way I was able to stop reentrant calls. Even if I think you should not show a UI from your converter, you can try this technique with the MS grid. Maybe it will work. However, I think your grid won't gain the focus back when the message box is closed. But this is to be tested. Best regards, Nicolas Cadilhac @ VisualHint Smart PropertyGrid.Net Microsoft PropertyGrid Resource List Free PropertyGrid for MFC Smart FieldPackEditor.Net / DateTimePicker
-
Propertygrid, need BeforePropertyChange-EventHi Martin, I'm sorry but you won't be able to do that with the MS PropertyGrid. Smart PropertyGrid.Net allows to do it though (through a PropertyChanging event). Best regards, Nicolas Cadilhac @ VisualHint Smart PropertyGrid.Net Microsoft PropertyGrid Resource List Free PropertyGrid for MFC Smart FieldPackEditor.Net / DateTimePicker
-
problem with propertygridHi, Your converter should derive from BooleanConverter. Just override the ConvertTo and ConvertFrom methods to change the display strings. Best regards, Nicolas Cadilhac @ VisualHint Smart PropertyGrid.Net Microsoft PropertyGrid Resource List Free PropertyGrid for MFC Smart FieldPackEditor.Net / DateTimePicker
-
DateTimePickerHi, The Microsoft DateTimePicker must be given a value type (a DateTime) and therefore can't accept null values. There are a lot of more or less usable solutions to solve this issue, some can be found here on CodeProject. If a commercial solution is an option, I would recommend Smart FieldPackEditor.Net which has been built from the ground up to solve all the DateTimePicker shortcomings.
Best regards, Nicolas Cadilhac @ VisualHint Smart PropertyGrid.Net Microsoft PropertyGrid Resource List Free PropertyGrid for MFC Smart FieldPackEditor.Net / DateTimePicker
-
Populate Property Grid with Datatable rowsThe best paper for that is http://msdn.microsoft.com/msdnmag/issues/05/05/NETMatters/. But read the first part too: http://msdn.microsoft.com/msdnmag/issues/05/04/NETMatters
Best regards, Nicolas Cadilhac @ VisualHint Smart PropertyGrid.Net Microsoft PropertyGrid Resource List Free PropertyGrid for MFC Smart FieldPackEditor.Net / DateTimePicker
-
How to create Properties Dynamically in Property gridThe Microsoft PropertyGrid, in the way it is available to the developer, is not really suitable for the end-user. It's not flexible enough and does not offer enough customization options. But a PropertyGrid in itself, is really suitable in so many cases... If it's done well, it can do the job better than any other control. I have written a paper some time ago showcasing a lot of examples in the industry: Why use a PropertyGrid in your application?
Best regards, Nicolas Cadilhac @ VisualHint Smart PropertyGrid.Net Microsoft PropertyGrid Resource List Free PropertyGrid for MFC Smart FieldPackEditor.Net / DateTimePicker
-
How to create Properties Dynamically in Property gridHello Dave, There is not a lot of detailed informations in the original post. So I gave a generic advice since the OP seems to ignore that the PropertyGrid can display something else than the simple sum of the public properties in a target instance. How he will get the data in his business objects and how he knows their type is beyond my knowledge of his application.
Best regards, Nicolas Cadilhac @ VisualHint Smart PropertyGrid.Net Microsoft PropertyGrid Resource List Free PropertyGrid for MFC Smart FieldPackEditor.Net / DateTimePicker
-
Populate Property Grid with Datatable rowsHi Dana, You can put whatever you want in a PropertyGrid as long as you write a class that will publish the properties you want. It has to implement ICustomTypeDescriptor. If you drop it to the SelectedObject property, you will see the custom properties. With .Net 2.0 you can also use the TypeDescriptionProvider so that you don't have to modify your existing class (the DataTable) to make it implement ICustomTypeDescriptor. You will find some resources about this subject on the PropertyGrid Resource List. If a commercial component is an option for you, you have also Smart PropertyGrid. It has a mode where you can simply call AppendProperty-like methods and fill the grid completely dynamicall without having to build separate TypeDescriptor classes. I hope this helps.
Best regards, Nicolas Cadilhac @ VisualHint Smart PropertyGrid.Net Microsoft PropertyGrid Resource List Free PropertyGrid for MFC Smart FieldPackEditor.Net / DateTimePicker
-
How to create Properties Dynamically in Property gridHi, simply write a class implementing ICustomTypeDescriptor and drop it to the SelectedObject property. This class will take care of publishing the properties it wants. With .Net 2.0 you can also use the TypeDescriptionProvider so that you don't have to modify your existing class to make it implement ICustomTypeDescriptor. You will find some resources about this subject on the PropertyGrid Resource List. If a commercial component is an option for you, you have also Smart PropertyGrid. It has a mode where you can simply call AppendProperty-like methods and fill the grid completely dynamicall without having to build separate TypeDescriptor classes. I hope this helps.
Best regards, Nicolas Cadilhac @ VisualHint Smart PropertyGrid.Net Microsoft PropertyGrid Resource List Free PropertyGrid for MFC Smart FieldPackEditor.Net / DateTimePicker