vb.net - Preventing column auto sort after editing a bound DataGridView -
I've got a DataGridView that is a DataTable as it is the data source. Whenever I sort a column and then edit a cell, after editing the column, the column autosource so the recently edited cell is no longer in the viewable area. Is there any way to stop it from happening like this and just like when I click on the column? Many thanks in advance. Daryn
I do not think there is a way to prevent type, But before you can store rows, columns, and update the values of the sort grid and then restore them after the update
Here is some of the code I use. Friends sub refreshGrid () dim row integer dim as integer as dim dim as gridcol integer as integer dim grid colons as integer dim rowCountOrig as integer dim rowCountNew integer line As = dgvReadOnly.CurrentRow.Index col = dgvReadOnly.CurrentCell.ColumnIndex string sortVal as string sortVal = _setSource.DefaultView.Sort rowCountOrig = _setSource.Rows.Count_setSource = _displaySet.displaySetTable RowCountNew = _setSource.Rows.Count RAFILTRATOR ( ) _setSource.DefaultView.Sort = sort Val (rowCountNew & gt; rowCountOrig) 'new line row = DgvReadOnly.RowCount added - 1 "is at the bottom of the new line grid, but leave the row finally dgvReadOnly.DataSource = nothing dgvReadOnly.DataSource = _setSource row & gt; = DgvReadOnly.RowCount - 1 then after 'Delete Row = dgvReadOnly.RowCount - 2 end then row & gt; = 0 'then' if matching filter dgvReadOnly.CurrentCell = dgvReadOnly (col, line) end then End Sub
Comments
Post a Comment