I have a DataGridView bound to a DataView. A certain points I
temporarily sort the DataGridView on specific columns to build filter
lists. During these "temporary" sorts on the DataView I would
like stop the sort from being applied on the DataGridView, which causes
it to redraw. Then after the filter list is created I reapply the
DataGridView's last sort.
ComboBoxes have BeginUpdate() and EndUpdate() for when changes are made
to the bound list. Is there something along the same lines for
the DataGridView
Thanks,
Nate

Is there BeginUpdate() functionality for the DataGridView?
Pablo Espada
jockofett
skl5973
Edmundas
beechy34
Daniel.Alvarez
Filters like in Excel when you select AutoFilter I see. You should really use another DataView or use Select on the DataTable (I think Select is more appropriate).
DataView keeps filtered and sorted rows from DataTable, but each row is a reference. Overhead is not too much, for 100 000 items your app will temporarily need about 400KB memory, I think it's acceptable in most cases.
Christopher Lukas
Well, you can actually turn off DataSource in DataGridView before sort and rebind to it after sort.
Perhabs you need this. If you want to sort with multiple columns, then simple write bs.Sort="ColumnOne DESC,ColumnTwo DESC". So all sorting done in single call.
Fleurin
HerbF
Jeff Filek
I guess I could keep a seperate DataView around and apply the sort there. It would be a valid option, but I wonder how much overhead there is in keeping another DataView in memory for very large lists.
Jesse990
Public Class Form1
Private bs As BindingSource
Private dt As DataTable
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
dt = New DataTable
dt.Columns.Add("ColumnOne", GetType(String))
dt.Columns.Add("ColumnTwo", GetType(String))
dt.Rows.Add(New String() {"One", "Nine"})
dt.Rows.Add(New String() {"Two", "Eight"})
dt.Rows.Add(New String() {"Three", "Seven"})
dt.Rows.Add(New String() {"Four", "Six"})
dt.Rows.Add(New String() {"Five", "Five"})
dt.Rows.Add(New String() {"Six", "Four"})
dt.Rows.Add(New String() {"Seven", "Three"})
dt.Rows.Add(New String() {"Eight", "Two"})
dt.Rows.Add(New String() {"Nine", "One"})
bs = New BindingSource(dt, "")
dgv1.DataSource = bs
'-- default sort of ColumnOne DESC
bs.Sort = "ColumnOne DESC"
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
bs.SuspendBinding()
'-- I want these sorts to be applied to the BindingSource but not redrawn in the DataGridView.
bs.Sort = "ColumnTwo DESC"
MessageBox.Show("Note that the sort has been applied to the DataGridView.")
bs.Sort = "ColumnOne DESC"
bs.ResumeBinding()
End Sub
End Class
John Valente - MSFT
polachan
I did find that DataView.ToTable allows me to specify distinct results, and I can specify a subset of columns for output. This should work for making distinct lists. Except, I still have the sorting problem. It would have been a great feature to allow ToTable to sort the data being returned.
GamePgmr
Hi!
You can get BindingManagerBase from BindingContext and call SuspendBinding()/ResumeBinding().