Game Development Reference
In-Depth Information
[TypeConverter(typeof(PropertyOrderConverter))]
public class PersonnelRecord
{
// …
}
NOTE
I did have a workaround for category ordering in Microsoft .NET 1.1, but this workaround had unde-
sired results when used with .NET 2.0. At this point in time, I have not figured out a way to do this.
Using the PropertyGrid
With a bindable class created and a custom TypeConverter created to handle prop-
erty ordering, using the PropertyGrid control is super easy. All you need to do is
drag the PropertyGrid control from the Visual Studio .NET toolbox onto your
form. The only other thing you need to do now is set the SelectedObject property
of the PropertyGrid , to an instance of our bindable class PersonnelRecord .
Figure 20.2 shows the PropertyGrid control item in the Visual Studio .NET toolbox.
Figure 20.2
Screenshot of the PropertyGrid control
item in the Visual Studio .NET toolbox.
The following code snippet shows the load event for the main form in the accom-
panying example. Notice how easy it is to instantiate our PersonnelRecord , set some
initial values, and then bind it to the PropertyGrid .
private void MainForm_Load(object sender, EventArgs e)
{
PersonnelRecord record = new PersonnelRecord();
record.FirstName = “John”;
record.LastName = “Smith”;
record.PhoneNumber = “555-123-4567”;
record.Email = “john.smith@company.com”;
record.BirthDate = Convert.ToDateTime(“1980-04-10”);
record.HairColor = Color.Brown;
record.EyeColor = Color.Blue;
record.Gender = Gender.Male;
 
Search Nedrilad ::




Custom Search