c# - winforms
On Form1 I have a Button and a Label (Label1)
ButtonClick:
Form2 Form2 = new Form2();
Form2.ShowDialog();
On Form2 I have a dgv
Form2.ClosingEvent:
string abc = Form2.dgv.CurrentCell.Value.ToString();
Form1.Label1.Text = abc;
How could I do this?
Loading

VulpesPosted Apr 15, 2012, 11:01 AM
MementoPosted Apr 15, 2012, 11:08 AM
I just replaced:
f1.Controls["Label1"].Text = abc;
with:
f1.Label1.Text = abc;
-it works.
ThankYou!!!
MementoPosted Apr 15, 2012, 10:28 AM
I got error: Object reference not set to an instance of an object.
Label1 is not direcrtly on Form1, but in a TabControl1 - TabPage1 - GroupBox1
I tried:
f1.Controls["TabControl1.TabPage1.GroupBox1.Label1"].Text = abc; - the same error.
There is no possibility to change Form1 design. TabControl is full docked. I have no room to place Label1 outside of TabControl.
Could yo write the solution in that case, pls.
I cheked:
f1.Controls["Label1"].Text = abc;
MessageBox.Show(abc);
-it works.
Also, modifiers for Label1 are - Public.
VulpesPosted Apr 15, 2012, 9:42 AM