datagridview, bindingnavigator add/delete strange behaviour

N

NetNewbie

Hi,

I noticed the following behaviour with datagridview(DGV). I am hoping
someone can suggest me the solution. I have several DGV's in my application
through which
data can be entered/modified/deleted. All the DGV are database bound.

I also have binding navigators for each of the DGV's. From my testing, I
noticed that one can enter a new row in 2 ways.
a) by clicking in the last row in DGV after scrolling down.
b) by clicking on the addnew button in the binding navigator/toolstrip.

for a) I noticed that the new row has a * and an arrow on the same row. But
for b) I noticed that the * is on a different row and the arrow on a
diffrent row, so there are 2 empty rows at the end

Now when a row is entered using option a) and then user clicks delete from
the bindingnavigator, 2 rows get deleted. This means a row is unintentionally
deleted. For option b) since there were 2 rows (with a * and an arrow), the
delete operation does not affect an actual row.

Has anybody else seen this behaviour ? I hope I was able to explain it
clearly. Any help on how to have the same delete behaviour no matter how a
new row is created will be greatly helpful.

Thank you
 
N

NetNewbie

My sol: I have disabled the Datagridview tasks's Enable Adding. So there is
no empty row at the bottom of the grid to start with. Only way is to click
the BN addnew button.

One thing to keep in mind is that if this task is disabled and you have BS
addingNew and currentChanged events defined and are using the newRowindex or
current row index, the values are drastically different. You will have to use
the BS.position to get the appropriate row index if u are using this event to
add default values
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top