G
Guest
I am using VS 2005 to develope a WindowsForms application. In the application
I have a TextBox control which I am trying to use as data input to an
incremental search and positioning of the current row in a DataGridView,
which is sourced through a DataSource to a DataSet containing a DataTable.
The code I am using is:
private void BaseLocation_toolStripTextBox_TextChanged(object
sender, EventArgs e)
{
if (BaseLocation_toolStripTextBox.Text.Length > 0)
{
string searchStr = "PLACENAME like '" +
BaseLocation_toolStripTextBox.Text + "%'";
DataRow[] selectedRows =
registrationPlaceListDataSet.RegistrationPlaceList.Select(searchStr);
if (selectedRows.Length > 0)
{
int selectedKey = (int)selectedRows[0]["KeyField"];
int index =
registrationPlaceListBindingSource.Find("KeyField", selectedKey);
registrationPlaceListBindingSource.Position = index;
}
}
}
The TextBox looses focus after entry of a character and if I click it to
reestablish focus it looses focus on each additional character entered.
Any help in understanding what is happening and how I might retain focus in
the TextBox will be appreciated.
Regards;
I have a TextBox control which I am trying to use as data input to an
incremental search and positioning of the current row in a DataGridView,
which is sourced through a DataSource to a DataSet containing a DataTable.
The code I am using is:
private void BaseLocation_toolStripTextBox_TextChanged(object
sender, EventArgs e)
{
if (BaseLocation_toolStripTextBox.Text.Length > 0)
{
string searchStr = "PLACENAME like '" +
BaseLocation_toolStripTextBox.Text + "%'";
DataRow[] selectedRows =
registrationPlaceListDataSet.RegistrationPlaceList.Select(searchStr);
if (selectedRows.Length > 0)
{
int selectedKey = (int)selectedRows[0]["KeyField"];
int index =
registrationPlaceListBindingSource.Find("KeyField", selectedKey);
registrationPlaceListBindingSource.Position = index;
}
}
}
The TextBox looses focus after entry of a character and if I click it to
reestablish focus it looses focus on each additional character entered.
Any help in understanding what is happening and how I might retain focus in
the TextBox will be appreciated.
Regards;