Home All Groups Group Topic Archive Search About

sorting inherited BindingList

Author
8 Feb 2006 5:09 PM
guy
VB2005
a generic collection that inherits from BindingList, with the code to
support sorting added

(ApplySortCore, SpportsSortingCore etc.)

however when this collection is populated and bound to a DataGridView
ApplySortCore is not called when a grid header is clicked.

how do i ensure this happens?

zzzzz

Author
8 Feb 2006 6:19 PM
Bart Mermuys
Hi,

"guy" <g**@discussions.microsoft.com> wrote in message
news:E4DA86FE-4C3C-449C-8B3A-277BF38739F6@microsoft.com...
> VB2005
> a generic collection that inherits from BindingList, with the code to
> support sorting added
>
> (ApplySortCore, SpportsSortingCore etc.)
>
> however when this collection is populated and bound to a DataGridView
> ApplySortCore is not called when a grid header is clicked.

A basic setup shows that ApplySortCore is called when SupportsSortingCore
returns True and you click on a column header.

So, not sure why it doesn't work for you, how did you setup the binding ?
Creating a Data Source for your Custom List isn't enough, you still need to
assign the actually list at form load:

Suppose CustomerList inherits from BindingList(Of Customer), a Data Source
was created and dragged on the Form, then you need to add the following
code:

Private _CustomerList As New CustomerList()
Private Sub Form_Load()
   CustomerListBindingSource.DataSource = _CustomerList
End Sub

HTH,
Greetings


Show quoteHide quote
>
> how do i ensure this happens?
>
> zzzzz
Author
10 Feb 2006 9:50 AM
guy
thanks Bert,
the binding works, the gris correctly displays the data however clicking the
column header has no effect

the code is simply

collection.load                     ' this works
grid.DataSource = collection 'this works
but the column header click never goes anywhere


Show quoteHide quote
"Bart Mermuys" wrote:

> Hi,
>
> "guy" <g**@discussions.microsoft.com> wrote in message
> news:E4DA86FE-4C3C-449C-8B3A-277BF38739F6@microsoft.com...
> > VB2005
> > a generic collection that inherits from BindingList, with the code to
> > support sorting added
> >
> > (ApplySortCore, SpportsSortingCore etc.)
> >
> > however when this collection is populated and bound to a DataGridView
> > ApplySortCore is not called when a grid header is clicked.
>
> A basic setup shows that ApplySortCore is called when SupportsSortingCore
> returns True and you click on a column header.
>
> So, not sure why it doesn't work for you, how did you setup the binding ?
> Creating a Data Source for your Custom List isn't enough, you still need to
> assign the actually list at form load:
>
> Suppose CustomerList inherits from BindingList(Of Customer), a Data Source
> was created and dragged on the Form, then you need to add the following
> code:
>
> Private _CustomerList As New CustomerList()
> Private Sub Form_Load()
>    CustomerListBindingSource.DataSource = _CustomerList
> End Sub
>
> HTH,
> Greetings
>
>
> >
> > how do i ensure this happens?
> >
> > zzzzz
>
>
>
Author
10 Feb 2006 10:09 AM
guy
Bert,

it was a typo

SupportSortingCore() instead of
SupportsSortingCore()

grrrrrrrrrrrrrrrrrrrrrrrrr

Show quoteHide quote
"Bart Mermuys" wrote:

> Hi,
>
> "guy" <g**@discussions.microsoft.com> wrote in message
> news:E4DA86FE-4C3C-449C-8B3A-277BF38739F6@microsoft.com...
> > VB2005
> > a generic collection that inherits from BindingList, with the code to
> > support sorting added
> >
> > (ApplySortCore, SpportsSortingCore etc.)
> >
> > however when this collection is populated and bound to a DataGridView
> > ApplySortCore is not called when a grid header is clicked.
>
> A basic setup shows that ApplySortCore is called when SupportsSortingCore
> returns True and you click on a column header.
>
> So, not sure why it doesn't work for you, how did you setup the binding ?
> Creating a Data Source for your Custom List isn't enough, you still need to
> assign the actually list at form load:
>
> Suppose CustomerList inherits from BindingList(Of Customer), a Data Source
> was created and dragged on the Form, then you need to add the following
> code:
>
> Private _CustomerList As New CustomerList()
> Private Sub Form_Load()
>    CustomerListBindingSource.DataSource = _CustomerList
> End Sub
>
> HTH,
> Greetings
>
>
> >
> > how do i ensure this happens?
> >
> > zzzzz
>
>
>