Properties of Properties

N

Nathan Sokalski

I have a System.Web.UI.Control which has a property of type
System.Drawing.Font. When editing this control in an *.aspx file, how do I
assign a value to this property? If I recall correctly, the attributes in
the server tag are a combination of the property name and the property of
that property separated by a "-" or something. However, I would also like to
be able to use the Property Grid to do this. I tried using the Browsable
attribute for the property, but that did not seem to help. Here is my
current code for the property:

<System.ComponentModel.Browsable(True)> WriteOnly Property Font() As
System.Drawing.Font
Set(ByVal value As System.Drawing.Font)
Me._font = value
End Set
End Property

Am I forgetting something? Any help would be appreciated. Thanks.
 
B

bruce barker

in general the property designer only support simple types by default
(string, numbers, enum). while the designer knows about color and size,
window fonts are not included. you will need to write your own prop designer
to support them. in the asp.net syntax, all properties must be able to be
specified as a string.

as fonts are specified to the browser via a style command, not sure why you
do not just support a style and class (CSSClass) properties.


-- bruce (sqlwork.com)
 
N

Nathan Sokalski

My reason for not using a style and class is because the control will be
generating an image, and therefore needs a System.Drawing.Font object.
Assuming you are correct in your statements, I will probably need to just
make separate properties and use the System.Drawing.Font constructor to
create the font. I was just hoping to not need to make separate properties,
but I guess that's all I can do for now since I don't know how to make
Property Designers yet (and there probably wouldn't be much point in this
case, since I only have one control that would need it). Thanks.
 
J

John Saunders

You should be able to work with this property in the property grid. The
System.Drawing.Font type has an associated editor, which the property grid
should expose to you.

What happens in the property grid?
 
N

Nathan Sokalski

All the Property Grid shows is the name of the property and a place to enter
a value. It shows up the same way a property of type String or Integer or
would. Is there an Property Attribute I need to add to make the associated
editor available? Thanks.
 

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

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top