I'm trying to create a simple AD Gui for our HR department to use but I'm hung up on something simple. Our email address format is [email protected]. I have a text box for first name and for last name and I want the text box for the email to autofill with [email protected]. I tried
string FirstName = txtBoxFirstName.text;
string LastName = txtBoxLastName.text;
txtBoxEmail.Text = FirstName + "." + LastName + "@organization.org";
I also tried not setting them as strings, but that didn't work either. I even tried to have the Email text box fill after the "Last Name" text box loses focus by putting
private void txtBoxLastName_Leave(object sender, System.EventArgs e)
{
txtBoxEmail.Text = txtBoxFirstName.text + "." + txtBoxLastName.text + "@organization.org";
}
I'm making this in a Windows Form application in Visual Studio Express 2013
Some more Info, I'm very VERY new to this. I've done a lot of searching on the web and nothing seems to be fully fitting my usage case to the point that it's fixed it. In response to a question, here's a more complete code snippet:
private void txtBoxLastName_Leave(object sender, System.EventArgs e)
{
string FirstName = txtBoxFirstName.Text;
string LastName = txtBoxLastName.Text;
txtBoxEmail.Text = FirstName + "." + LastName + "@lgfcu.org";
}
This shows that they're in the txtBoxLastName_Leave.
I'm going to take a stab in the dark and assume that you didn't actually wire the event to the TextBox. Easiest way to create an event: Right click on your TextBox, click properties, select the "lightning symbol" toward the top, find the event you desire ("leave" in this case) and double click the column to the right of "Leave". This will wire the event (look in your designer.cs file for a
+=
) and create the method for you.Alternatively, if you want to wire the event manually add this code (after
InitializeComponent()
):