![]() |
![]() |
|
|||||||
| Register | Forum Rules | Getting Started! - Guide | Blog | Videos | Gallery | Members List | Social Groups | Mark Forums Read |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Guest
Posts: n/a
|
Datagrid not automatically updating Datatable
I have a Datagrid that is bound to a Datatable at runtime. I allow the
user to select a number of rows using the mouse and then click a button that says "check selected rows", which then cycles through the selected rows and sets a check box field in the datagrid (and thus the databound datatable) to checked/true. It works like this: Dim cel As DataGridViewCheckBoxCell For Each row In DataGrid.SelectedRows cel = row.Cells(0) cel.Value = True Next I then have a property / function I expose that should show me the number of currently checked rows. It looks like this: Public ReadOnly Property CheckedRowCount() As Integer Get Dim v As DataView = New DataView(DataTable) v.RowFilter = "[Selected]=true" Return v.Count End Get End Property When I select a set of rows and then click the button that runs the first set of code, the property represented by the second set is always ONE LESS than the number of rows selected. It's like it's not automatically marking the last databound datarow as updated... is there a way to force this? I've tried programmatically changing the CurrentCell property of the datagrid to another row, and this works, but it doesn't look good at all, and the user loses the cells they selected. Any ideas? P.S. I have also tried updating the underlying datarow instead of the cell value, as in: For Each row In DataGrid.SelectedRows dim dr as datarow= CType(row.DataBoundItem, DataRowView).Row dr(0)=true Next |
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
< Home - Windows Help - MS Office Help - Hardware Support >
| New To Site? | Need Help? |