c# - Remove Uncommitted New Rows Of DGV -


I have unbound DGV and I want to delete its unwanted last line on the DGV Leave event hander . How to do this ?.

I know that DGV has to programmatically add new rows and set property AllowUserToAddRows = false.

But I have a question: Is it possible to extract the last line without permission of DGV property? USeriododdroz = false?

OR

Is it possible to remove unlimited new lines of DGV?

Set DataGridView AllowUserToAddRows property to False .

However, you must provide a method that will allow the user to enter a new line. For example, you can see that when users double-click the Data Grid view, you set AllowUserToAddRows to True. And then when they make edits, you put the value back to false.

To add a new row:

Say your datagroup view has a myadatgrid view and you have a button called BTNADROV and when the button clicks , It adds a new row to your datagrid view.

  Private Zero btnAddRow_Click (Object Sender, RoutedEventArgs e) {// Add an empty row MyDataGridView.Rows.Add (); }   

Alternatively, you can only handle DataGridView OnDoubleClick events in which you can type MyDataGridView.Rows.Add () Can call new line

Comments