Click here to Skip to main content
13,087,566 members (93,331 online)
Rate this:
Please Sign up or sign in to vote.
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.Text = "";
                        SqlCeCommand year_comm = new SqlCeCommand("SELECT DISTINCT year FROM vehicles ORDER BY year DESC", conn);
                        year_comm.CommandType = CommandType.Text;
                        SqlCeDataReader year_dr = year_comm.ExecuteReader();
                        while (year_dr.Read())

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.
Posted 17-May-13 3:25am
Sergey Alexandrovich Kryukov 17-May-13 10:33am
The problem might be not in the code you show. If you need anyone to look at it, you should make a very different code sample. One of the ways to do it is to create complete code in one file, without using the designer, all in manually written C# code, which is quite possible.

By the way, if it won't reproduce the problem, it will already give you enough food for thought.

joshrduncan2012 17-May-13 10:38am
Thanks SA. I'm trying to satisfy the boss. I know he's gonna look at it and wonder why it's doing that before we present this to the client. I know there is an event that I'm missing that I can't figure out how to prevent that from happening.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web02 | 2.8.170813.1 | Last Updated 17 May 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100