hi
i have a project containing 2 forms. DB connection info is on form1 and i want to access this data from form2 - the data resides in textbox controls, but i cant "see" them from form2?? Something need the "public" keyword or???
Printable View
hi
i have a project containing 2 forms. DB connection info is on form1 and i want to access this data from form2 - the data resides in textbox controls, but i cant "see" them from form2?? Something need the "public" keyword or???
Hi there,
Have a look at this thread first:
http://vbforums.com/showthread.php?t=481564
thanks, it looks promissing :)
hi again
i tried the approach described in the post, but i dont get any of the values. Other ways of doing this?
modify the constructor of Form2 to reference Form1...
Make the Control you wish to access Public instead of Private ( Modifiers = Public )
and in Form1, to call form2 ...Code:/// Form2 ...
public partial class Form2 : Form
{
private Form1 frm;
public Form2(Form f)
{
frm = (Form1)f;
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show(frm.textBox1.Text);
}
}
Code:Form2 frm2 = new Form2(this);
frm2.Show();
Thanks for your help guys, but i solved it by creating a class containing connection info, and pass this to the Show() method. Works like a charm :)
Nice idea :)Quote:
Originally Posted by carstenht
thank you :p