المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : DataGridView: for customized pasting operation first row is moved to end of the grid instead of getting overwritten!!!!



C# Programming
08-24-2009, 01:32 PM
I have derived a custom control from the DataGridView to enable pasting operation from the Clipboard. I am able to do almost all the operation of pasting except the following

Scenario :
1. Added the custom DataGridView to form
2. AlloUserToAddRows = true and I have also set some other required property of custom DataGridView
3. when I turn AlloUserToAddRows = true , VS adds a one default row to grid
4. so I used the following steps to reproduce the bug
a. I run application and paste the data in each cell individually on the default added row it does not add any additional row to grid
b. I copied some rows from excel sheet and tried to paste in grid by selected first cell (as current cell)
c. Programmatically, I have to calculate the number of rows required to add in grid for pasting operation which I did , and using this.Rows.Add(n); to add n number of rows (I also tried with Insert())
d. While using Add() function everything works fine except that the first row is moved to end of the grid (only in the above mentioned scenario; for everything else it works fine)
e. While using Insert () method overloads, I am getting the exception (on same line in debug mode) InvalidOperationException with message as “no row can be inserted after the uncommitted new row.”
5. I tried many things to get work around for this bug, however I didn’t succeeded


Anybody knows the any approach where I can either get rid of this bug or exception?
suggestions are also welcome!!



Reg,
Deep

Happy Coding