String and forms
-
hello, this may have been asked before but i am still having trouble with getting a string onto another form, i have searched google etc and still don't get it as many differant articles tell you differant things etc ... all i need to do is get my string from form 2 to form 1..... my code for my string .....
string findme = txtfind.Text;
thanks
-
hello, this may have been asked before but i am still having trouble with getting a string onto another form, i have searched google etc and still don't get it as many differant articles tell you differant things etc ... all i need to do is get my string from form 2 to form 1..... my code for my string .....
string findme = txtfind.Text;
thanks
-
hello, this may have been asked before but i am still having trouble with getting a string onto another form, i have searched google etc and still don't get it as many differant articles tell you differant things etc ... all i need to do is get my string from form 2 to form 1..... my code for my string .....
string findme = txtfind.Text;
thanks
You may wanna read this article: Passing Values between Forms in .NET 1.x with C# and VB.NET examples[^]
:bob: Kristian Sixhoej I have noticed even people who claim everything is predestined, and that we can do nothing to change it, look before they cross the road. - Stephen Hawking
-
hello, this may have been asked before but i am still having trouble with getting a string onto another form, i have searched google etc and still don't get it as many differant articles tell you differant things etc ... all i need to do is get my string from form 2 to form 1..... my code for my string .....
string findme = txtfind.Text;
thanks
There are a lot of possible ways and a lot of possible scenaries where you transfer a string from the one form to another. A very simple way is to associate the both form. That means, that form 1 has a instance for form 2 or reversed. So you have to make sure, that the properties from form 2 are public that you wan't to set from form 1. Here a small example of a association of two forms:
public partial class Form1 : Form { public Form2 Form2 { get; set; } public Form1() { InitializeComponent(); } private void button1\_Click(object sender, EventArgs e) { Form2.MyStringIfWantToSet = "Hello World"; } } public partial class Form2 : Form { public string MyStringIfWantToSet { get { return textBox1.Text; } set { textBox1.Text = value; } } public Form2() { InitializeComponent(); } }
[STAThread]
static void Main() {
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);Form1 form1 = new Form1(); Form2 form2 = new Form2(); form1.Form2 = form2; form2.Show(); Application.Run(form1); }
I really hope i could help, sorry for my english...
-
hello, this may have been asked before but i am still having trouble with getting a string onto another form, i have searched google etc and still don't get it as many differant articles tell you differant things etc ... all i need to do is get my string from form 2 to form 1..... my code for my string .....
string findme = txtfind.Text;
thanks
A tip[^] that will give you the code... An article[^] which will explain it and more.
Dave
If this helped, please vote & accept answer!
Binging is like googling, it just feels dirtier. (Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) -
hello, this may have been asked before but i am still having trouble with getting a string onto another form, i have searched google etc and still don't get it as many differant articles tell you differant things etc ... all i need to do is get my string from form 2 to form 1..... my code for my string .....
string findme = txtfind.Text;
thanks
in form2 declare public property public string FindText; you can access this property, like this string find = from1.FindText;
The big boss!
-
in form2 declare public property public string FindText; you can access this property, like this string find = from1.FindText;
The big boss!