0

hi,
i work on windows application and i want to know how to use the components (textboxes,..) of a winform in another winform.
thanks

2
Contributors
2
Replies
5
Views
7 Years
Discussion Span
Last Post by basma.lm
1

Here's an example:

Form1's Constructor:

Form2 form2;

public Form1()
{
    InitializeComponent();

    form2 = new Form2(this);
}

Form2's Constructor:

Form1 form1;

public Form2(Form1 F)
{
    InitializeComponent();

   form1 = F;
}

Now set the Modifiers property of the control (on any form) to "Public":

[img]http://i.imgur.com/IzNSu.jpg[/img]

And you can then access it like this:

Accessing a Label on Form2 from Form1:

// Form1

string labelText = form2.label1.Text;

Hope that helps.

Thanks

Edited by farooqaaa: n/a

Votes + Comments
THANK YOU THANK YOU
0

Thank you so much for the code you really help me. thanks again...

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.