Home All Groups Group Topic Archive Search About

Sorting a datagrigview

Author
6 Nov 2006 1:53 PM
Stéphane_Miqueu
Hi,

I sort my datagridview with : dgWrk.Sort(dgWrk.Columns(3),...
and it works perfect. Now, I want it sorted on 2 columns. How did I do
that ? I've try dgWrk.Sort(dgWrk.Columns(3)+dgWrk.Columns(4)+ ...
but I have an error in the code editor.

Thanks

--
Ami Calmant
Stéphane

Author
6 Nov 2006 2:05 PM
Norman Chong
Stéphane Miqueu schrieb:

> Hi,
>
> I sort my datagridview with : dgWrk.Sort(dgWrk.Columns(3),...
> and it works perfect. Now, I want it sorted on 2 columns. How did I do
> that ? I've try dgWrk.Sort(dgWrk.Columns(3)+dgWrk.Columns(4)+ ...
> but I have an error in the code editor.
>

Hi Stéphane,

AFAIK, the '+' operator won't work here and the Sort(...) method can
only get 1 column, no collection. Doesn't it work when you just call
dgWrk.Sort(dgWrk.Columns(3))
dgWrk.Sort(dgWrk.Columns(2)) ?

(Maybe you need a dgWrk.update() call between the .sort())
Author
6 Nov 2006 2:17 PM
Stéphane_Miqueu
Norman Chong a présenté l'énoncé suivant :
> Hi Stéphane,
>
> AFAIK, the '+' operator won't work here and the Sort(...) method can
> only get 1 column, no collection. Doesn't it work when you just call
> dgWrk.Sort(dgWrk.Columns(3))
> dgWrk.Sort(dgWrk.Columns(2)) ?
>
> (Maybe you need a dgWrk.update() call between the .sort())

Well done Norman, it was just under my nose. I was doing the sorting in
the wrong order : col3 then col4 whereas col4 THEN col3 is doing just
fine.

Thanks !

--
Ami Calmant
Stéphane