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();
Loading

Sanjeeb LenkaRank #301 · 8.3K reputationPosted Jul 8, 2013, 10:22 PM EDT
Iftikar HussainRank #423 · 5.9K reputationPosted Jul 8, 2013, 11:03 PM EDT
You can do this on Mouse Enter event of LastName textbox
this.TxtBxLastName.MouseEnter += new System.EventHandler(this.TxtBxLastNameMouseEnter);
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();
Regards,
Iftikar