Custom Control - inherit child properties?

A

Andrew

Hey All,
I'm building a custom control that contains a
System.Web.UI.WebControls.Calendar object and am wondering about how to
make the calendar's many properties appear in my control's property
window. I could make a bunch of public properties like
Calendar_TodayBackColor, and map them internally to <internal calendar
object>.TodayDayStyle.BackColor, but there are SO many! There must be an
easier way.

TIA,
Andrew
 
V

Victor Garcia Aprea [MVP]

Hi Andrew,

Not sure if I'm getting right your question. If you inherit from Calendar
then all Calendar's public properties will be already shown in the
properties window. Now, for any new property added to your type you will
need some code to define it and do any mappings, ie:
[C#]
public YourPropertyType YourPropertyName{
get{ return MappedPropertyName;}
set{ MappedPropertyName = value;}
}

The properties window will automatically show this new public property.

If you're looking for something different, please give some more details
about it,

--
Victor Garcia Aprea
Microsoft MVP | ASP.NET
Looking for insights on ASP.NET? Read my blog:
http://obies.com/vga/blog.aspx
To contact me remove 'NOSPAM'. Please post all questions to the newsgroup
and not by private mail.
 
A

Andrew

Hi Victor,

Actually, my control inherits directly from
System.Web.UI.WebControls.WebControl, not Calendar. It is a custom
control made up of a textbox, and imagebutton, and a calendar. I was just
hoping that since the calendar has probably over a hundred seperate style
properties, there would be some way to "automagically" add them to my
control's property window instead of making over a hundred seperate public
properties....
 
V

Victor Garcia Aprea [MVP]

Ok, what you can do is to create a custom designer (see
System.Web.UI.Design.ControlDesigner) for your control and make it provide
all the properties you want (see ControlDesigner.PreFilterProperties). This
way you dont have to actually add new properties to your custom control.

--
Victor Garcia Aprea
Microsoft MVP | ASP.NET
Looking for insights on ASP.NET? Read my blog:
http://obies.com/vga/blog.aspx
To contact me remove 'NOSPAM'. Please post all questions to the newsgroup
and not by private mail.

Andrew said:
Hi Victor,

Actually, my control inherits directly from
System.Web.UI.WebControls.WebControl, not Calendar. It is a custom
control made up of a textbox, and imagebutton, and a calendar. I was just
hoping that since the calendar has probably over a hundred seperate style
properties, there would be some way to "automagically" add them to my
control's property window instead of making over a hundred seperate public
properties....


Hi Andrew,

Not sure if I'm getting right your question. If you inherit from
Calendar then all Calendar's public properties will be already shown in
the properties window. Now, for any new property added to your type you
will need some code to define it and do any mappings, ie: [C#]
public YourPropertyType YourPropertyName{
get{ return MappedPropertyName;}
set{ MappedPropertyName = value;}
}
}
The properties window will automatically show this new public property.

If you're looking for something different, please give some more details
about it,
 
A

Andrew

Excellent, i'll start looking into the ControlDesigner.PreFilterPrperties.
You wouldn't happen to know of any good samples anywhere would you, MSDN
is pretty sad when it comes to sample code...
 
V

Victor Garcia Aprea [MVP]

I don't have any simple samples handy. Do a quick search on
msdn.microsoft.com for articles written by Shawn Burke (MS), he has couple
of very good articles about design-time stuff, including the use of
PreFilterProperties if I remember correctly.

--
Victor Garcia Aprea
Microsoft MVP | ASP.NET
Looking for insights on ASP.NET? Read my blog:
http://obies.com/vga/blog.aspx
To contact me remove 'NOSPAM'. Please post all questions to the newsgroup
and not by private mail.
 

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,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top