problem with PropertyGrid


F

Frank Skare

Hello,
I have a class which has a property which
is the type of another class which has
a property as well. I expected a node
but it seems I'm missing something. Does
anybody know how to access the entire object?

Regards,
Frank

------------------------

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs)
PropertyGrid1.SelectedObject = New TestClass1
End Sub

Public Class TestClass1
Public Property TestProperty() As TestClass2
Get
Return New TestClass2
End Get
Set
End Set
End Property
End Class

Public Class TestClass2
Public Property TestProperty() As String
Get
Return ""
End Get
Set
End Set
End Property
End Class

-------------------------

private void Form1_Load(object sender, System.EventArgs e)
{
propertyGrid1.SelectedObject = new TestClass1();
}

public class TestClass1
{
public TestClass2 TestProperty
{
get
{
return new TestClass2();
}
set
{
}
}
}

public class TestClass2
{
public string TestProperty
{
get
{
return "";
}
set
{
}
}
}
 
Ad

Advertisements

J

Jan Tielens

Check out these articles if you need to find out more about the
PropertyGrid:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/usingpropgrid.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/vsnetpropbrow.asp
One of the great features of the Visual Studio .NET property browser is the
ability to display nested properties, allowing for a more granular and
logical level of grouping than categories. Nested properties are also
available in both categorized and alphabetical sort mode. It helps keep
property lists compact-instead of both a Left and Top property, just a
Location property that is expandable into X and Y will do for a separate
entry.

But what determines whether or not a property is expandable? The answer is
not in the property itself, but rather in the Type of property. In the .NET
Framework, each type has associated with it a TypeConverter. The
TypeConverter for types such as Boolean or string prevents them from being
expandable in the property browser. It would make little sense to have
sub-properties for type Boolean!

TypeConverters actually perform several functions within the .NET Framework
and particularly within the property browser. As its name suggests,
TypeConverters provide a standard way of dynamically converting values from
one Type to another. The property browser, for example, only works with
strings directly, so it relies on TypeConverters to take those string values
and convert them to the Type that the property expects, and vice versa.
TypeConverters also control expandability and allow complex types to work
seamlessly with the property browser.
 
Ad

Advertisements

F

Frank Skare

Thanks for the fast reply, it's described in the first article.

Cheers,
Frank
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top