How to autopopulate a textbox with data we entered in previous textbox in C# .net 2.0

Posted by Kumartyr under C# on 7/9/2013 | Points: 10 | Views : 1592 | Status : [Member] | Replies : 1
i have two textbox in a form and will be typing firstname and lastname in that two textbox

what i want is if i type a name in first textbox and do tab or mouseclick to next textbox i want the matching lastname of the firstname
to be automatically populated

how to do this... i have written the below coding but am not able to find which textbox event will be appropriate to do this..
please someone clarify my doubt

if (LastNameTextBox.Text == "")
{
ACSCLN = new AutoCompleteStringCollection();
ORCMND13 = new OracleCommand("Select LASTNAME from VMS_VISITOR where FIRSTNAME='" + FirstNameTextBox.Text + "'", CON);
DR22 = ORCMND13.ExecuteReader();

if (DR22.HasRows == true)
{
while (DR22.Read())
{
ACSCLN.Add(DR22["LASTNAME"].ToString());
}

LastNameTextBox.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
LastNameTextBox.AutoCompleteSource = AutoCompleteSource.CustomSource;
LastNameTextBox.AutoCompleteCustomSource = ACSCLN;
}
LastNameTextBox.Focus();




Responses

Posted by: Vuyiswamb on: 7/9/2013 [Member] [MVP] [Administrator] NotApplicable | Points: 25

Up
0
Down
The Best Event is "TextChanged"


Thank you for posting at Dotnetfunda
[Administrator]

Kumartyr, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response