Care with DataGrid's CurrentrowIndex operation DataTable

xiaoxiao2021-03-06  47

'In the case of the DataGrid allowsorting value is true, it is not much Row that uses CurrentrowIndex to take the corresponding ROW in DataTable.

After random sorting, CurrentrowIndex and DataTable "currentrowindex" may not match,

'DataTable1.Rows [DataGrid1.currentrowIndex] may not be what you really want.

'Sustact method can be like this:

DIM Mycurrencymanager as CurrencyManager

Private Sub Form1_Load (Byval E AS System.Object, Byval E AS System.Eventargs) Handles MyBase.Load

'...

Mycurrencymanager = me.bindingcontext (dataGrid1.datasource, DataGrid1.datamember)

End Sub

Private sub Button2_click (byvalgend, byval e as system.eventargs) Handles Button2.click

CType (MyCurrencymanager.current, DataRowView) .row.delete ()

End Sub

转载请注明原文地址:https://www.9cbs.com/read-116210.html

New Post(0)