Click here to Skip to main content
15,890,282 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a gridview which inside a couple of button and Combobox and a textbox. and the problem is as i start to type in textbox a new line do appear. I dont why? no code behind textboxes text.
i think i need to ask question like this
How to prevent Datagridview to not create next row. until i click on specific button
Posted
Updated 2-Nov-13 6:46am
v2

1 solution

You need to set the property AllowUserToAddRows to False (this can be done at design time or programmatically e.g. this.dataGridView1.AllowUserToAddRows = false;).

Your button to add the next row will need to add a row, then position the cursor for user input e.g.
C#
int i = this.dataGridView1.Rows.Add();
this.dataGridView1.CurrentCell = dataGridView1.Rows[i].Cells[0];
dataGridView1.BeginEdit(true);
 
Share this answer
 
v2
Comments
CHill60 2-Nov-13 13:21pm    
Apologies - I've misspelled it ... try this.dataGridView1.AllowUserToAddRows = false;
Muhamad Faizan Khan 2-Nov-13 13:20pm    
wonderful my five

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