Reputation: 1
I'm working on setting up a login form for an existing application. I'm currently having issues with getting the value of one of the text boxes in a class.
For example Form9 has a textbox called txtchannel. I'm wanting to get the value of what's in txtchannel in the class.
// Revision
I was finally able to get it to take the command using the following
// Class
private void DoConnect()
{
try
{
jtvClient.Connect();
jtvClient.JoinChannel("#" + this.mainForm.txtChan.Text);
}
catch (Exception ex)
{
op.Post(x => OnExceptionThrown((Exception)x), ex); // TODO: double check that exceptions
} // actually show up at this level
}
private Login mainForm = null;
public JtvClient(Login derp)
{
mainForm = derp as Login;
}
////
This is allowing me to at the very least call the what is in Login(Now Formally Form9). However it gives an error "Object reference not set to an instance of an object.". I'm at a complete loss.
Upvotes: 0
Views: 81
Reputation: 2226
I think the Text property of the TextBox class is what you are looking for. See MSDN for the full documentation on TextBox.Text
.
Upvotes: 2
Reputation: 5305
The best way to get the value in another class (if you mean another class), is to expose a property called Channel
in Form9
. The would look like this:
public string Channel
{
get
{
return txtChannel.Text;
}
}
Upvotes: 1