Now change your form’s Load event to browse an instance of this class in the Property Grid control: It contains properties that are having data types. Public Property StringProperty() As Stringįor now, this class is much like any one you wrote. Public Property DecimalProperty() As Decimal Public Property BooleanProperty() As Boolean So here is a useless class which only serves as a demonstration of the features of the PropertyGrid control: It means that your class instances can be shown. Pretty much any object can be passed to the SelectedObject property. Because properties are affecting the form (or any other control), you can see immediately the effect of your modifications without having to stop and restart your applications (much what you can do from the Autos, Locals, and Watch windows but within a familiar look).įilling the control with your own objectsĭisplaying your own objects in the control is not different. I agree that you do not want to bind forms to the property grid to let the user modify their properties at runtime but you can hide something for your own use. Tell me if you can find the (Name) property! I finally want to bring to your attention that some properties are not visible. For example, try to enter letters into a numeric property like Size.Width (an error will be raised and the value will not be accepted). As soon as you hit Enter, the caption of the form will be changed to whatever you typed! Try to change some other values.
And to prove that it is not just a browser, change some properties like the Text property. The description band is also already working as expected. The Categorized and Alphabetic buttons are already working as expected. So what you see in the PropertyGrid control are the properties of the form. The SelectedObject property receives the object that the PropertyGrid control needs to display. What is Me? It is an object containing the current form’s instance. So to prove it, add this very simple line to your form’s Load event and execute it: Everything you used in your application is an object so it means that everything can be bound to the PropertyGrid! I have said in the introduction that the control can be used with objects of your applications. Now we need something to interact with the control. You already see the 3 bands of the PropertyGrid control (the dialog toolbar, the properties band, and the description band). You will surely recognize a dialog that is familiar.
From the ".Net Framework Components", find the PropertyGrid control (if you have more than one, be sure to use the one that is in the namespace).Īdd an instance of the PropertyGrid control to your form. So open the "Customize Toolbox" dialog (by right-clicking the Toolbox and clicking the "Add/Remove items." menu item or by using the "Add/Remove Toolbox items." menu item from the Tools menu). I am sure you will find a place to put it in your own applications before you have completed the reading of this column! This control is not very used probably because programmers didn’t find it yet. The PropertyGrid control uses Reflection to inspect your object and to display the properties using a decent editor.
These objects are not required to be controls. The PropertyGrid control can be used to browse, view, and edit properties of one or more objects of your own application. It is called the PropertyGrid control.Īs you’ll soon discover, the control Microsoft gave us is pretty basic (not surprisingly!!!) but is also flexible and The VS.Net IDE? This control is now available to you right from the box.
DescriptionHave you ever needed a control in your own application having the same features as the properties dialog you use everyday to set the properties of forms and/or controls into