Home All Groups Group Topic Archive Search About

SortCompare of DataGridView - how to?

Author
22 May 2006 2:40 PM
Chris Botha
VS2005 and I have a DataTable displayed in a DataGridView that needs custom
sorting, with the DataSource of the grid set to the DataTable and the
SortCompare event just won't fire.

Then I found this in  the docs "This event occurs only when the DataSource
property is not set and the VirtualMode property value is false"
This seems really odd but may be true. I can't see what the purpose of this
event is then, how else will one use the DataGridView other than setting the
DataSource to something?

How else to do the custom sorting when the user clicks a column header is
also welcome.

Thanks.

Author
22 May 2006 2:56 PM
Ken Tucker [MVP]
Chris,

      It fires when the datagridview is not bound to a datasource and
virtual mode is set to false.

Ken
-----------------------

Show quoteHide quote
"Chris Botha" wrote:

> VS2005 and I have a DataTable displayed in a DataGridView that needs custom
> sorting, with the DataSource of the grid set to the DataTable and the
> SortCompare event just won't fire.
>
> Then I found this in  the docs "This event occurs only when the DataSource
> property is not set and the VirtualMode property value is false"
> This seems really odd but may be true. I can't see what the purpose of this
> event is then, how else will one use the DataGridView other than setting the
> DataSource to something?
>
> How else to do the custom sorting when the user clicks a column header is
> also welcome.
>
> Thanks.
>
>
>
Author
22 May 2006 3:20 PM
Chris Botha
Hi Ken, thanks for the quick response. If you have it working, then I need
more assistance please. I've seen it in the docs, but what the heck does "is
not bound to a datasource" mean?
In my case I have a typed DataSet dataset obtained with a Web service call,
and sets the DataSource of the grid to be the DataTable in the dataset. Does
this cause the event not to fire? As mentioned, this seems really odd. Is
there another way of displaying the table in the grid other than setting the
datasource to the table so the event will fire?
I've tried the VirtualMode property in both its flavors and read all 3 pages
of links coming back with Google searching for DataGridView SortCompare.


Show quoteHide quote
"Ken Tucker [MVP]" <KenTucker***@discussions.microsoft.com> wrote in message
news:E3355A9A-88FA-4790-A26F-26B4F5556B89@microsoft.com...
> Chris,
>
>      It fires when the datagridview is not bound to a datasource and
> virtual mode is set to false.
>
> Ken
> -----------------------
>
> "Chris Botha" wrote:
>
>> VS2005 and I have a DataTable displayed in a DataGridView that needs
>> custom
>> sorting, with the DataSource of the grid set to the DataTable and the
>> SortCompare event just won't fire.
>>
>> Then I found this in  the docs "This event occurs only when the
>> DataSource
>> property is not set and the VirtualMode property value is false"
>> This seems really odd but may be true. I can't see what the purpose of
>> this
>> event is then, how else will one use the DataGridView other than setting
>> the
>> DataSource to something?
>>
>> How else to do the custom sorting when the user clicks a column header is
>> also welcome.
>>
>> Thanks.
>>
>>
>>
Author
22 May 2006 4:24 PM
Ken Tucker [MVP]
Hi,

             Not bound to a datasource means that you add the columns and
cell values manually.

Here is a link to an example.
http://www.onteorasoftware.com/blog.aspx?BlogID=2

Ken
------------------------------
Show quoteHide quote
"Chris Botha" wrote:

> Hi Ken, thanks for the quick response. If you have it working, then I need
> more assistance please. I've seen it in the docs, but what the heck does "is
> not bound to a datasource" mean?
> In my case I have a typed DataSet dataset obtained with a Web service call,
> and sets the DataSource of the grid to be the DataTable in the dataset. Does
> this cause the event not to fire? As mentioned, this seems really odd. Is
> there another way of displaying the table in the grid other than setting the
> datasource to the table so the event will fire?
> I've tried the VirtualMode property in both its flavors and read all 3 pages
> of links coming back with Google searching for DataGridView SortCompare.
>
>
> "Ken Tucker [MVP]" <KenTucker***@discussions.microsoft.com> wrote in message
> news:E3355A9A-88FA-4790-A26F-26B4F5556B89@microsoft.com...
> > Chris,
> >
> >      It fires when the datagridview is not bound to a datasource and
> > virtual mode is set to false.
> >
> > Ken
> > -----------------------
> >
> > "Chris Botha" wrote:
> >
> >> VS2005 and I have a DataTable displayed in a DataGridView that needs
> >> custom
> >> sorting, with the DataSource of the grid set to the DataTable and the
> >> SortCompare event just won't fire.
> >>
> >> Then I found this in  the docs "This event occurs only when the
> >> DataSource
> >> property is not set and the VirtualMode property value is false"
> >> This seems really odd but may be true. I can't see what the purpose of
> >> this
> >> event is then, how else will one use the DataGridView other than setting
> >> the
> >> DataSource to something?
> >>
> >> How else to do the custom sorting when the user clicks a column header is
> >> also welcome.
> >>
> >> Thanks.
> >>
> >>
> >>
>
>
>
Author
22 May 2006 5:07 PM
Chris Botha
Ken, thanks again, seems like the link does not work though?

Show quoteHide quote
"Ken Tucker [MVP]" <KenTucker***@discussions.microsoft.com> wrote in message
news:F4EB6888-7BBD-4CAC-B99F-2EAF81146F84@microsoft.com...
> Hi,
>
>             Not bound to a datasource means that you add the columns and
> cell values manually.
>
> Here is a link to an example.
> http://www.onteorasoftware.com/blog.aspx?BlogID=2
>
> Ken
> ------------------------------
> "Chris Botha" wrote:
>
>> Hi Ken, thanks for the quick response. If you have it working, then I
>> need
>> more assistance please. I've seen it in the docs, but what the heck does
>> "is
>> not bound to a datasource" mean?
>> In my case I have a typed DataSet dataset obtained with a Web service
>> call,
>> and sets the DataSource of the grid to be the DataTable in the dataset.
>> Does
>> this cause the event not to fire? As mentioned, this seems really odd. Is
>> there another way of displaying the table in the grid other than setting
>> the
>> datasource to the table so the event will fire?
>> I've tried the VirtualMode property in both its flavors and read all 3
>> pages
>> of links coming back with Google searching for DataGridView SortCompare.
>>
>>
>> "Ken Tucker [MVP]" <KenTucker***@discussions.microsoft.com> wrote in
>> message
>> news:E3355A9A-88FA-4790-A26F-26B4F5556B89@microsoft.com...
>> > Chris,
>> >
>> >      It fires when the datagridview is not bound to a datasource and
>> > virtual mode is set to false.
>> >
>> > Ken
>> > -----------------------
>> >
>> > "Chris Botha" wrote:
>> >
>> >> VS2005 and I have a DataTable displayed in a DataGridView that needs
>> >> custom
>> >> sorting, with the DataSource of the grid set to the DataTable and the
>> >> SortCompare event just won't fire.
>> >>
>> >> Then I found this in  the docs "This event occurs only when the
>> >> DataSource
>> >> property is not set and the VirtualMode property value is false"
>> >> This seems really odd but may be true. I can't see what the purpose of
>> >> this
>> >> event is then, how else will one use the DataGridView other than
>> >> setting
>> >> the
>> >> DataSource to something?
>> >>
>> >> How else to do the custom sorting when the user clicks a column header
>> >> is
>> >> also welcome.
>> >>
>> >> Thanks.
>> >>
>> >>
>> >>
>>
>>
>>