Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: SQL-CE C# DataGridView Forms , +
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.
Posted 17-May-13 4:25am
Comments
Sergey Alexandrovich Kryukov at 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.
 
—SA
joshrduncan2012 at 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
0 DamithSL 265
1 CPallini 235
2 OriginalGriff 233
3 Maciej Los 195
4 George Jonsson 170
0 OriginalGriff 5,305
1 DamithSL 4,382
2 Maciej Los 3,760
3 Kornfeld Eliyahu Peter 3,470
4 Sergey Alexandrovich Kryukov 2,901


Advertise | Privacy | Mobile
Web02 | 2.8.141216.1 | Last Updated 17 May 2013
Copyright © CodeProject, 1999-2014
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