Populate Property Grid with Datatable rows
-
Hi all, Can we able to populate a property grid using a A datatabel For example, Like this PropertyGrid1.SelectedObject=Datatable1 or some any other method exist Thanks in Advance Dana
-
Hi all, Can we able to populate a property grid using a A datatabel For example, Like this PropertyGrid1.SelectedObject=Datatable1 or some any other method exist Thanks in Advance Dana
A property grid simply doesn't work that way. You can't give it a bunch of database rows and expect it to display them. A PropertyGrid control shows you the public properties of an object, like an instance of a TextBox, Label, DataGridView, ... It does NOT show the rows of a database table. For that, you'd need to use a DataGridView, or some other bindable grid control.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007 -
Hi all, Can we able to populate a property grid using a A datatabel For example, Like this PropertyGrid1.SelectedObject=Datatable1 or some any other method exist Thanks in Advance Dana
Hi 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
-
Hi 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
Hi Nicolas, Thanks for your reply Can u please brief about this one 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 Thanks to Dave also :) Dana
-
Hi Nicolas, Thanks for your reply Can u please brief about this one 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 Thanks to Dave also :) Dana
The 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