|
-
Aug 10th, 2007, 06:03 AM
#1
Thread Starter
Addicted Member
access other forms
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???
-
Aug 10th, 2007, 08:35 AM
#2
Re: access other forms
Hi there,
Have a look at this thread first:
http://vbforums.com/showthread.php?t=481564
-
Aug 10th, 2007, 08:54 AM
#3
Thread Starter
Addicted Member
Re: access other forms
thanks, it looks promissing
-
Aug 10th, 2007, 11:48 AM
#4
Thread Starter
Addicted Member
Re: access other forms
hi again
i tried the approach described in the post, but i dont get any of the values. Other ways of doing this?
-
Aug 10th, 2007, 12:06 PM
#5
Re: access other forms
modify the constructor of Form2 to reference Form1...
Make the Control you wish to access Public instead of Private ( Modifiers = Public )
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);
}
}
and in Form1, to call form2 ...
Code:
Form2 frm2 = new Form2(this);
frm2.Show();
~
if a post is resolved, please mark it as [Resolved]
protected string get_Signature(){return Censored;}
[vbcode][php] please use code tags when posting any code [/php][/vbcode]
-
Aug 10th, 2007, 01:57 PM
#6
Thread Starter
Addicted Member
Re: access other forms
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
-
Aug 10th, 2007, 07:27 PM
#7
Hyperactive Member
Re: access other forms
 Originally Posted by carstenht
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
____________________________________________
Please rate my messages. Thank you!
____________________________________________
Bram Vandenbon
http://www.bramvandenbon.com
-
Aug 11th, 2007, 01:02 AM
#8
Thread Starter
Addicted Member
Re: access other forms
thank you
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|