Click here to Skip to main content
15,888,610 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
C#
 private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
                       
if (e.RowIndex >= 0 && e.ColumnIndex==4 && ((DataGridView)sender).Columns[e.ColumnIndex].GetType() ==  typeof(DataGridViewButtonColumn))
              {
                  DataGridViewRow row = (DataGridViewRow)dataGridView1.Rows[0].Clone();
                  dataGridView1.Rows.Add(row);
               }
        }

I am using the above code to generate another row in Gridview on button click which is working fine on button click but the problem is when i do Combo box click or do textboxes text change (Comboboxes and Textboxes are also include in Gridview's Row with button) a new row appear automatically without the running of above code. how new row i appearing i didnt do any code
Posted
Updated 30-Oct-13 7:28am
v2

1 solution

Hard to understand your question - so excuse me if I'm wrong: but you are "filtering" for
e.ColumnIndex==4 and typeof(DataGridViewButtonColumn) both can't be true for your textboxes comboboxes... No?
 
Share this answer
 
Comments
Muhamad Faizan Khan 2-Nov-13 12:20pm    
DataGridview Generating new row when i try to write in Textbox or try to select any item in combo box

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900