Reputation: 151
My c# program says this. I don't know how to fix this for I am new with c#. Pleas help me T_T. Thanks!
public partial class Form1 : Form
{
private void btnGenerateUserID_Click(object sender, EventArgs e)
{
textBox4.Text(User.GenerateUserID);
}
private void btnGenerateUsername_Click(object sender, EventArgs e)
{
textBox5.Text(User.GenerateUsername(Name.Text, MI.Text, Lastname.Text));
}
}
Upvotes: 1
Views: 2109
Reputation: 66439
You cannot "call" the Text
property. You have to assign it a string like this:
textBox4.Text = User.GenerateUserID.ToString();
textBox5.Text = User.GenerateUsername(Name.Text, MI.Text, Lastname.Text);
There is an AppendText()
method that may have confused you, if you saw that in an example. Like the name suggests, it simply appends more text to the end of whatever's already in the TextBox
:
textBox4.AppendText(User.GenerateUserID.ToString());
Upvotes: 1
Reputation: 223187
TextBox.Text
is a property, its not a method. You need to assign value to the property.
textBox4.Text = User.GenerateUserID; //assuming its string or call User.GetUserID.ToString();
If User.GetUserID
is a method then you need to call it like:
textBox4.Text = User.GenerateUserID();
If the returned value is not string, then you can call ToString
on it like:
textBox4.Text = User.GenerateUserID().ToString(); //check for null before calling
//ToString
Do the same for:
textBox5.Text = User.GenerateUsername(Name.Text, MI.Text, Lastname.Text);
Upvotes: 4