Control Behavior

  • Thread starter Thread starter Jimmy V
  • Start date Start date
J

Jimmy V

Hey guys and gals,

I am creating a composite control and need to expose the ImageList and
all related properties of a label in this control; I do not want to
expose the entire label. What I am looking for is a way to get the
ImageKey and ImageIndex properties to behave the same as they do with
the base label control, i.e. I want to a drop down with the available
values in the ImageKey and ImageIndex in the property window when a
user adds the control to their form. Any ideas on how I can expose
these properly? I want them to have the same return types as their
respective values. Am I missing something very easy or is this a more
involved problem?

Thanks,

Jimmy V
 
Jimmy,

Well, creating something with the appropriate return types is easy, just
expose ImageIndex and ImageKey properties on your component which will just
forward the calls to the underlying imagelist control.

To get designer support, you should look at those properties on the
Label in Reflector. If you do, you will see that there are some attributes
that are attached to the property. You want to copy these attributes to the
same properties on your control. The attributes you want are:

DefaultValue
Editor
RefreshProperties
TypeConverter

Once you apply those, it should give you what you want.
 
Jimmy,

Well, creating something with the appropriate return types is easy, just
expose ImageIndex and ImageKey properties on your component which will just
forward the calls to the underlying imagelist control.

To get designer support, you should look at those properties on the
Label in Reflector. If you do, you will see that there are some attributes
that are attached to the property. You want to copy these attributes to the
same properties on your control. The attributes you want are:

DefaultValue
Editor
RefreshProperties
TypeConverter

Once you apply those, it should give you what you want.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)




Hey guys and gals,
I am creating a composite control and need to expose the ImageList and
all related properties of a label in this control; I do not want to
expose the entire label. What I am looking for is a way to get the
ImageKey and ImageIndex properties to behave the same as they do with
the base label control, i.e. I want to a drop down with the available
values in the ImageKey and ImageIndex in the property window when a
user adds the control to their form. Any ideas on how I can expose
these properly? I want them to have the same return types as their
respective values. Am I missing something very easy or is this a more
involved problem?

Jimmy V- Hide quoted text -

- Show quoted text -

Awesome Nick, that did the trick, I'm gonna have to go and study my
attribute classes!
 

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

Back
Top