Set text box text based on character list
So, I have the following form:
What I am trying to achieve is the following:
After entering the name, I want the initials of the name to be generated by simply clicking the initials text box.
I found the following method to get the first characters of a string:
string EngineerName = tb_Name.Text.ToString();
EngineerName.Split(' ').ToList().ForEach(i => Console.Write(i[0] + " "));
My question is, how would I assign a list of characters to the text textbox
?
I tried:
private void Tb_Initials_Click(object sender, EventArgs e)
{
string EngineerName = tb_Name.Text.ToString();
EngineerName.Split(' ').ToList().ForEach(i => Console.Write(i[0] + " "));
tb_Initials.Text = EngineerName;
}
But this just populates the textbox with the same name ...
+3
source to share