andrewting
asked on
Deleting row from datagrid when the 'asterix' row appears selected
I'm trying to allow a user to delete a row from a datagrid (whose datasource is a datatable) using a 'Delete Row' button. To do this I:
Private Sub DeleteRowButton_Click(ByVa l sender As System.Object, ByVal e As System.EventArgs) Handles DeleteRowButton.Click
Dim dTotal As Decimal
Dim deletedDataRow As DataRow1
Dim cm As CurrencyManager = CType(Me.BindingContext(Tr ansactionD ataGrid.Da taSource, TransactionDataGrid.DataMe mber), CurrencyManager)
Dim transactionDataView As DataView = CType(cm.List, DataView)
cm.RemoveAt(cm.Position)
End Sub
The problem occurs when the user is on the new row (asterix row) of the datatable and tries to delete this row. Instead of the 'asterix' row being deleted it deletes the previous row that was current. I think this occurs because the current row does not change when you click on the 'asterix' row but can appear that it way because it is highlighted. One solution I have tried is to determine if a row is the 'asterix' row. Unfortunately I have not found a way to identify this.
Any insight on this problem would be greatly appreciated. If you require some more information, please let me know.
Thanks in advance for your help.
Private Sub DeleteRowButton_Click(ByVa
Dim dTotal As Decimal
Dim deletedDataRow As DataRow1
Dim cm As CurrencyManager = CType(Me.BindingContext(Tr
Dim transactionDataView As DataView = CType(cm.List, DataView)
cm.RemoveAt(cm.Position)
End Sub
The problem occurs when the user is on the new row (asterix row) of the datatable and tries to delete this row. Instead of the 'asterix' row being deleted it deletes the previous row that was current. I think this occurs because the current row does not change when you click on the 'asterix' row but can appear that it way because it is highlighted. One solution I have tried is to determine if a row is the 'asterix' row. Unfortunately I have not found a way to identify this.
Any insight on this problem would be greatly appreciated. If you require some more information, please let me know.
Thanks in advance for your help.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks amyhxu. Your solution worked perfectly.
http://www.syncfusion.com/FAQ/WinForms/FAQ_c44c.asp#q823q