Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I cannot acces the choosen properties from new component

Status
Not open for further replies.

clemenslinders

Programmer
Oct 26, 2006
2
NL
LS,

I'm using VS 2005 C#. I created a new component that inherits form textbox. I added a Label to this textbox.

private Label tBLabel;
[Description("Label above Textbox.")]
public Label TBLabel
{
get { return tBLabel; }
set { tBLabel = value; }
}

private void InitializeTB()
{
tBLabel = new Label();
}


I can use my new component.
In the properties box I can see TBLabel
I can change the properties for TBLabel (for instance change it's Text to: This is a label)

But when I run the program the debugger shows me that textbox1.TBLabel.Text=empty

Probably the problem is that I during initialization I have to state tBLabel = new Label(); If I do not use this line I get an error.

Does anyone know how I can overcome this problem??

My guess is that it should be possible.

Kind regards,



Clemens Linders
 
I'm not sure I fully understand the problem but can you not just instantiate at declaration

private Label tBLabel = new Label();
 
Hi Julesey,

I tried:
private Label tBLabel=new Label();//+Instantiation
[Description("Label above Textbox.")]
public Label TBLabel
{
get { return tBLabel; }
set { tBLabel = value; }
}
and the problem remained.

The problem is that during designtime I can give the text property a value. Let's say "Enter your name here" and just below, there is the textbox where the name can be entered.

So I just gave textBox1.TBLabel.Text the value "Enter your name here" in the propertiesbox during designtime. When I run it the displayed label is empty. The debugger also shows: textbox1.TBLabel.Text=""

If I add a button with the code: textBox1.TBLabel.Text="KKK"; Than KKK shows above the textbox.

I would ofcourse like it if I could just use the propertiesbox during designtime to give my label.text it's value.

I hope this claryfies my problem.

Kind regards,


Clemens
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top