As a workaround for the problem, I think I have to handle KeyDown events to get the printable character that the user actually typed.
KeyDown provides me with a KeyEventArgs object with the properties KeyCode, KeyData, KeyValue, modifiers, Alt, Shift, Control.
My first attempt was to treat KeyCode as ascii code, but the KeyCode on my keyboard is 46, period ("."), So I end up printing the period when the user enters the delete key. So, I know that my logic is inadequate.
(For the curious, the problem is that I have my own combobox in the DataGridView control collection, and somehow SOME characters that I print do not trigger KeyPress and TextChanged ComboBox events. These letters include Q, $,% ....
This code will reproduce the problem. Create a form application and replace ctor with this code. Run it and try to enter the letter Q in two combo.
public partial class Form1 : Form
{
ComboBox cmbInGrid;
ComboBox cmbNotInGrid;
DataGridView grid;
public Form1()
{
InitializeComponent();
grid = new DataGridView();
cmbInGrid = new ComboBox();
cmbNotInGrid = new ComboBox();
cmbInGrid.Items.Add("a");
cmbInGrid.Items.Add("b");
cmbNotInGrid.Items.Add("c");
cmbNotInGrid.Items.Add("d");
this.Controls.Add(cmbNotInGrid);
this.Controls.Add(grid);
grid.Location = new Point(0, 100);
this.grid.Controls.Add(cmbInGrid);
}
source
share