L
lotus
HI All..
I'm realtively new to C#.
I have MainForm which includes Parent usercontol, and this parent
usercontrol also contains child usercontrol.
MainForm --> Parent usercontrol --> child usercontrol
Parent usercontol has one button to change the child usercontorl's
variable.
Child usercontrol has one textbox that display child usercontrol's
variable.
When I press button of parent usercontrol, I change the variabe of
child user control, and I want to display the variable to textbox.
But textbox does not change its value.
What kind of action do I need?
Any suggestion would be greatly appreciated.
oldfark
-----------------Sample Code start----------------
/////////Child usercontorl's code////////////////
public partial class ChildUC : UserControl
{
double val1=0;
public ChildUC()
{
InitializeComponent();
this.textBox1.Text = val1.ToString();
}
public void set_val(double i)
{
val1 = i;
}
}
/////////Parent usercontorl's code/////////////
public partial class ParentUC : UserControl
{
public ParentUC()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
this.childUC1.set_val(1000);
}
}
///////////// MainForm has deualt code --- no change to original
designer code////////////
------------------------Sample Code end-------------------------------
I'm realtively new to C#.
I have MainForm which includes Parent usercontol, and this parent
usercontrol also contains child usercontrol.
MainForm --> Parent usercontrol --> child usercontrol
Parent usercontol has one button to change the child usercontorl's
variable.
Child usercontrol has one textbox that display child usercontrol's
variable.
When I press button of parent usercontrol, I change the variabe of
child user control, and I want to display the variable to textbox.
But textbox does not change its value.
What kind of action do I need?
Any suggestion would be greatly appreciated.
oldfark
-----------------Sample Code start----------------
/////////Child usercontorl's code////////////////
public partial class ChildUC : UserControl
{
double val1=0;
public ChildUC()
{
InitializeComponent();
this.textBox1.Text = val1.ToString();
}
public void set_val(double i)
{
val1 = i;
}
}
/////////Parent usercontorl's code/////////////
public partial class ParentUC : UserControl
{
public ParentUC()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
this.childUC1.set_val(1000);
}
}
///////////// MainForm has deualt code --- no change to original
designer code////////////
------------------------Sample Code end-------------------------------