all groups > dotnet windows forms > may 2005 >
You're in the

dotnet windows forms

group:

Help having problems with UserControl



Help having problems with UserControl Kim
5/31/2005 4:09:18 PM
dotnet windows forms: I have a form that has a button in it when I click on the button I want the
textbox that is on the usercontrol to update. Ive tried:
//This is on the form
private void button1_Click(object sender, System.EventArgs e)
{
UserControl1 ctrl = new UserControl1();
ctrl.ClientName = "This is a test";
}
//This is on the usercontrol
public string ClientName
{
get
{
return this.textBox1.Text;
}
set
{
this.textBox1.text = value;
}
}
when I check the value is in the textbox but it doesn't update itself or
fire the event can someone tell me what Im doing wrong.
Thanks
Re: Help having problems with UserControl Tim Wilson
5/31/2005 7:37:45 PM
Unless the code that you're posting is some sort of pseudo code, it looks
like your creating an instance of your UserControl inside the Button Click
handler instead of using the instance that is on the Form.

private UserControl1 userControl1 = new UserControl1();

....

private void button1_Click(object sender, System.EventArgs e)
{
userControl1.ClientName = "This is a test";
}

--
Tim Wilson
..Net Compact Framework MVP

[quoted text, click to view]

AddThis Social Bookmark Button