Note that there are some explanatory texts on larger screens.

plurals
  1. POPassing Textbox values from a Textbox to a different (not form.cs) Class
    primarykey
    data
    text
    <p>Still new to C# .NET so simple (with explanation) is preferred. :) I have a Windows form with a few textboxes. I want to be able to read in the contents of these textboxes,<strong>in a separate file.</strong> I've seen articles (also here on stackoverflow) which cover similar problems, but don't work in my case. The data I want is to be found in textboxes in Form1. Where I want this data to go is -> myOtherCS, where it will be used in a method (Savedoc).</p> <p>In Form1.cs I have:</p> <pre><code>private myOtherCS allOtherMethods; public static string myText= ""; public static string mytitle = ""; public Form1() { InitializeComponent(); allOtherMethods = new myOtherCS(); } /* I would like the myText to be filled with the contents of Textbox1 * and mytitle to be filled with contents of Textbox2. Ideally when the * Textboxes have been changed. */ private void TextBox1_TextChanged(object sender, EventArgs e) { myText = Textbox1.Text; } private void TextBox2_TextChanged(object sender, EventArgs e) { myTitle = Textbox2.Text; } </code></pre> <p>In myOtherCS file I want to be able to use these values within a different method. So first probably "get" and "set"-ing them. I've tried a lot of things but here is one.. to get the idea from.. I do know that you have to change things in both files, and have, but this is to get the idea.</p> <pre><code>public class GetTextBoxes { private string title; private string text; public string Title { get { return title; } set { title = value; } } public string Text { get { return text; } set { text = value; } } } public void SaveDoc() { GetTextBoxes.title; GetTextBoxes.text; } </code></pre> <p>This is PSEUDOcode as of yet, to try to show what I want to do. I've tried many things, if someone knows how to do this, I would very much appreciate it! Thanks in advance</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload