473,466 Members | 1,367 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Composite Control font problem!

pnp
I have created a coposite user control of a text box and a label. I have
exposed the font of the textbox property through a property of the
control but every time I try to change that through the property grid of
the designer when I use the composite control in a form, after a rebuild
the changes seem to get lost! I don't see the Font property anywhere in
the inner code... What am I doing wrong?
Nov 17 '05 #1
3 3642
Can you post the code for the custom property that exposes the inner TextBox
Font property?

--
Tim Wilson
..Net Compact Framework MVP

"pnp" <pnp.@.softlab.ntua.gr> wrote in message
news:uA**************@TK2MSFTNGP09.phx.gbl...
I have created a coposite user control of a text box and a label. I have
exposed the font of the textbox property through a property of the
control but every time I try to change that through the property grid of
the designer when I use the composite control in a form, after a rebuild
the changes seem to get lost! I don't see the Font property anywhere in
the inner code... What am I doing wrong?

Nov 17 '05 #2
pnp
Tim Wilson wrote:
Can you post the code for the custom property that exposes the inner TextBox
Font property?

[Category("InputBox"), Browsable(true),
RefreshProperties(RefreshProperties.None)]
public override Font Font
{
get
{
return this.textbox.Font ;
}
set
{
this.textbox.Font = value;
}
}
Nov 17 '05 #3
You should be blowing the stack in your get accessor. When the child TextBox
Font property is queried it will attempt to return the Parent Font property
value - this is due to the Font property being an ambient property. So when
you get the TextBox Font property from within the Parent Font property, the
child attempts to get the parents value, but the parent is getting the
childs value -- stack overflow. Another way to do this is to set the Label
Font in the constructor.

public UserControl1()
{
// This call is required by the Windows.Forms Form Designer.
InitializeComponent();
this.label1.Font = this.Font;
}

Now, since the Label Font has been explicitly set, the Label will not pick
up the Font of the parent and so the Font property will affect the TextBox
only.

If you want to override the attributes for the Font property, just make sure
that you're using the base Font to get and set.

[Category("InputBox")]
public override Font Font
{
get
{
return base.Font;
}
set
{
base.Font = value;
}
}

--
Tim Wilson
..Net Compact Framework MVP

"pnp" <pnp.@.softlab.ntua.gr> wrote in message
news:OR**************@TK2MSFTNGP09.phx.gbl...
Tim Wilson wrote:
Can you post the code for the custom property that exposes the inner TextBox Font property?

[Category("InputBox"), Browsable(true),
RefreshProperties(RefreshProperties.None)]
public override Font Font
{
get
{
return this.textbox.Font ;
}
set
{
this.textbox.Font = value;
}
}

Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Sehboo | last post by:
Hi, Can anybody tell me how I can add composite properties to my control - just like Font property where you see a small '+' sign and user can click on it to open and see all the properties...
0
by: Mark Goldin | last post by:
I have created a Web composite control that consists of a label and Infragistics WebMaskEdit text box. When I drop that control on my form I have "Error Creating Control ..." thing. When I move a...
3
by: Mark Goldin | last post by:
I have created a Web composite control that consists of a label and Infragistics WebMaskEdit text box. When I drop that control on my form I have "Error Creating Control ..." thing. When I move a...
1
by: Mark Olbert | last post by:
I have a "master" composite control which, in turn, holds an instance of a "detail" composite control (the "master" control will ultimately contain multiple instances of the "detail" control, but...
4
by: Mark Olbert | last post by:
This involves a family of related, databound ASPNET2 composite controls. I've managed to arrange things so that the composite controls restore themselves from ViewState on postback after they're...
0
by: multiformity | last post by:
Ok, so I have gone off and documented the lifecycle of a page with a custom composite control on it. You can find that document here: http://www.ats-engineers.com/lifecycle.htm Now, I am...
3
by: Beavis | last post by:
I hate to repost a message, but I am still at the same point where I was when I originally posted, and hopefully someone else will see this one... Ok, so I have gone off and documented the...
3
by: Eric | last post by:
I have created a fairly basic composite control consisting of a Label and a TextBox. In the overridden Render function, I'm creating a table with two rows and each row contains a cell (td). The...
6
by: shapper | last post by:
Hello, I am working in a class library with various custom controls. In which cases should a control inherit Control, WebControl and CompositeControl classes? And when should a custom...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.