Link to home
Start Free TrialLog in
Avatar of andrewting
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(ByVal 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(TransactionDataGrid.DataSource, TransactionDataGrid.DataMember), 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.
Avatar of Brian Crowe
Brian Crowe
Flag of United States of America image

ASKER CERTIFIED SOLUTION
Avatar of amyhxu
amyhxu

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of andrewting
andrewting

ASKER

Thanks amyhxu. Your solution worked perfectly.