Hi everyone!
I have an issue with typing in zeros in a combobox that is layed over a datagridview cell. It essentially clears out everything in front of it. This only happens on the first time you enter the cell. If you retype in the same cell while that same cell is active, it lets you type in everything. Has anyone ever heard of this issue before? Can anyone shed some light as to what makes it behave that way? This is only happening when I try to enter a 4-digit year.
My datagridview cell click (relevant) code:
if (dataGridView1.CurrentCell.ColumnIndex == 3)
{
comboBox1.Show();
comboBox1.Items.Clear();
comboBox1.Text = "";
SqlCeCommand year_comm = new SqlCeCommand("SELECT DISTINCT year FROM vehicles ORDER BY year DESC", conn);
year_comm.CommandType = CommandType.Text;
year_comm.ExecuteNonQuery();
SqlCeDataReader year_dr = year_comm.ExecuteReader();
while (year_dr.Read())
{
comboBox1.Items.Add(year_dr["year"]);
}
}
My combobox text changed code:
private void comboBox1_TextChanged(object sender, EventArgs e)
{
if (comboBox1.Text != "")
{
dataGridView1.CurrentCell.Value = comboBox1.Text;
}
}
Any help/pointers will be appreciated.
If I type in "2014" in the first time, I should see 2014.
What I see the first time is after the 0, I don't see the 2 anymore until I retype it.