DataGridView, BindingSource and sorting in vb.net

I am emulating the functionality of an old application in VB.Net. I have a DataGridView in my form that is bound to a BindingSource. I have a button on the toolbar that displays a sort dialog. The sort dialog allows you to sort up to 3 columns.

So, I am building a string from the results of the dialog and setting the BindingSource.Sort property with it. But this doesn't update my DataGridView. I missed a step - do I need to say something to update?

+1


source to share


3 answers


I just tried it with a simple test app and it sorted out without having to refresh again. Can you post the code? Are you sure you are creating the sort string correctly?



+3


source


Do you need to call DataGridView.DataBind () method?



I'm so used to ASP.NET that I forgot the WinForms stuff.

+1


source


What is the main object and supports sorting? You can check through the .SupportsSorting property (iirc). If it's a DataTable then you should be fine.

Have you tried applying sorting directly to the grid?

You can try calling BindingSource.ResetBindings (false) after updating the sort property to be safe, but you don't need to.

0


source







All Articles