Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display control on another panel

I have on my winform two panels:on the first panel I have an usercontrol that can be multiplied dynamically. I want,on the second panel,to be displayed the usercontrol that is selected by the user. The idea is that,I want ,if I change the text at runtime of my usercontrol ,these changes to be displayed on the second panel too. I need an idea how can I do that. I am trying now to create properties for each object of my usercontrol and events,but I think is too much to do for this. . Thanks.
My code,what I have tried so far:

On my usercontrol I have created properties for each object that this contains. Code on usercontrol.cs:

  public string TextName
    {
        get { return textname.Text; }
        set { textname.Text = value; }
    }
    public string Task
    {
        get { return checkboxTip.Text; }
        set { checkboxTip.Text = value; }
    }
       .......
     and on my winform.cs I created an event for all properties:

    private void PropertiesChange_Click(object sender, EventArgs e)
 {
       textname1.Text=textname.Text; //textname1 is the textbox from usercontrol,and                     textname is from the second panel;
      checkboxTip1.Text-checkbox.Text;
    .....// I am doing this for each object,but I have 10 objects. 
like image 954
Viva Avatar asked Nov 13 '22 07:11

Viva


1 Answers

try this:

private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{

   textBox2.Text = textBox1.Text;
   // you can do anytihng here
}

assuming that textBox1 is on your 1st panel and textBox2 is at your 2nd.

like image 97
Mark Avatar answered Nov 15 '22 00:11

Mark