1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
private void BISMultiColumnComboBox_KeyPress(object sender, KeyPressEventArgs e)
{
ShowDropDown();
string strFindStr = "";
if (e.KeyChar == (char)8)
{
if (this.SelectionStart <= 1)
{
this.Text = "";
return;
}
if (this.SelectionLength == 0)
strFindStr = this.Text.Substring(0, this.Text.Length - 1);
else
strFindStr = this.Text.Substring(0, this.SelectionStart - 1);
}
else
{
if (this.SelectionLength == 0)
strFindStr = this.Text + e.KeyChar;
else
strFindStr = this.Text.Substring(0, this.SelectionStart) + e.KeyChar;
}
int intIdx = -1;
// Search the string in the ComboBox list.
if (this.MyDisplayMember != "" && this.MyValueMember != "" && this.MyDisplayMember != null && this.MyValueMember != null)
intIdx = FindIndex(this.userBisDataGridView1.MyBisDataGridView.Columns[this.MyDisplayMember].Index, strFindStr);
else
{
string Var = this.userBisDataGridView1.MyBisDataGridView.Columns[0].HeaderText;
intIdx = FindIndex(this.userBisDataGridView1.MyBisDataGridView.Columns[0].Index, strFindStr);
}
if (intIdx != -1)
{
this.MySelectedIndex = intIdx;
e.Handled = true;
this.Focus();
this.SelectionStart = strFindStr.Length;
this.SelectionLength = this.Text.Length;
}
else
{
e.Handled = true;
}
} |
Partager