How to sort a specific ColumnHeader of a ListView by program code 
Author Message
 How to sort a specific ColumnHeader of a ListView by program code

I've a Sample_ListView in ReportMode with several ColumnHeaders.
If you click on a ColumnHeader the following Sub is called to sort the
ColumnHeader.

  Private Sub Sample_ListView_ColumnClick(ByVal ColumnHeader As
ColumnHeader)
    With Laufzeiten_ListView
        If .SortKey = ColumnHeader.Index - 1 Then
          If .SortOrder = lvwAscending Then
            .SortOrder = lvwDescending
          Else
              .SortOrder = lvwAscending
            End If
        Else
          .SortKey = ColumnHeader.Index - 1
          .SortOrder = lvwAscending
        End If

        .Sorted = True
        .Refresh
    End With
  End Sub

But how can I sort for example the second ColumnHeader ascending by
program code?

I'm asking because I'd like to sort the second ColumnHeader ascending by
program code and later on I'd like to sort the

Sample_ListView like it was sorted before. But unfortunately I've no
idea how to program it.

An help is very appreciated
Stefan



Sun, 12 Sep 2004 15:11:19 GMT  
 How to sort a specific ColumnHeader of a ListView by program code
Stefan,

This popup menu routine leans on the listview's sorting technique which allows for sorting one key inside another.  In this case I
am sorting files names within directories prior to preparing an HTML listing:

Private Sub mHTML_File_Click()
  Dim hg As New HourGlass
  Set hg.Scope = ListView1
  hg.Pointer = vbHourglass

  With ListView1
    .SortKey = siFile
    .Sorted = True
    .SortOrder = lvwAscending
  End With

  With ListView1
    .SortKey = siPath
    .Sorted = True
    .SortOrder = lvwAscending
  End With

  DoHTML 1
End Sub

After this has been done the listview remains in this sorted order until the user chooses a column header sort, another popup menu
choice, or a fresh list!
HTH
--
Billy Joe

B J B 1 9 3 9  A T  H O T M A I L  D O T  C O M

Quote:

> I've a Sample_ListView in ReportMode with several ColumnHeaders.
> If you click on a ColumnHeader the following Sub is called to sort the
> ColumnHeader.

>   Private Sub Sample_ListView_ColumnClick(ByVal ColumnHeader As
> ColumnHeader)
>     With Laufzeiten_ListView
>         If .SortKey = ColumnHeader.Index - 1 Then
>           If .SortOrder = lvwAscending Then
>             .SortOrder = lvwDescending
>           Else
>               .SortOrder = lvwAscending
>             End If
>         Else
>           .SortKey = ColumnHeader.Index - 1
>           .SortOrder = lvwAscending
>         End If

>         .Sorted = True
>         .Refresh
>     End With
>   End Sub

> But how can I sort for example the second ColumnHeader ascending by
> program code?

> I'm asking because I'd like to sort the second ColumnHeader ascending by
> program code and later on I'd like to sort the

> Sample_ListView like it was sorted before. But unfortunately I've no
> idea how to program it.

> An help is very appreciated
> Stefan



Mon, 13 Sep 2004 00:02:35 GMT  
 How to sort a specific ColumnHeader of a ListView by program code
Wow, thanks a lot for your help.

Happy Easter
Stefan

Quote:

> Stefan,

> This popup menu routine leans on the listview's sorting technique which allows for sorting one key inside another.  In this case I
> am sorting files names within directories prior to preparing an HTML listing:

> Private Sub mHTML_File_Click()
>   Dim hg As New HourGlass
>   Set hg.Scope = ListView1
>   hg.Pointer = vbHourglass

>   With ListView1
>     .SortKey = siFile
>     .Sorted = True
>     .SortOrder = lvwAscending
>   End With

>   With ListView1
>     .SortKey = siPath
>     .Sorted = True
>     .SortOrder = lvwAscending
>   End With

>   DoHTML 1
> End Sub

> After this has been done the listview remains in this sorted order until the user chooses a column header sort, another popup menu
> choice, or a fresh list!
> HTH
> --
> Billy Joe

> B J B 1 9 3 9  A T  H O T M A I L  D O T  C O M


> > I've a Sample_ListView in ReportMode with several ColumnHeaders.
> > If you click on a ColumnHeader the following Sub is called to sort the
> > ColumnHeader.

> >   Private Sub Sample_ListView_ColumnClick(ByVal ColumnHeader As
> > ColumnHeader)
> >     With Laufzeiten_ListView
> >         If .SortKey = ColumnHeader.Index - 1 Then
> >           If .SortOrder = lvwAscending Then
> >             .SortOrder = lvwDescending
> >           Else
> >               .SortOrder = lvwAscending
> >             End If
> >         Else
> >           .SortKey = ColumnHeader.Index - 1
> >           .SortOrder = lvwAscending
> >         End If

> >         .Sorted = True
> >         .Refresh
> >     End With
> >   End Sub

> > But how can I sort for example the second ColumnHeader ascending by
> > program code?

> > I'm asking because I'd like to sort the second ColumnHeader ascending by
> > program code and later on I'd like to sort the

> > Sample_ListView like it was sorted before. But unfortunately I've no
> > idea how to program it.

> > An help is very appreciated
> > Stefan



Mon, 13 Sep 2004 15:31:31 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Putting sort-direction arrows on listview columnheaders.

2. ?Listview ColumnHeaders With Sorted Bitmap???

3. Sort Order arrows in ListView ColumnHeaders?

4. ?Listview ColumnHeaders With Sorted Bitmap???

5. ?Listview ColumnHeaders With Sorted Bitmap???

6. ListView: Column Text becomes Left-Aligned when ColumnHeader Icon is changed in Code

7. ListView: Column Text becomes Left-Aligned when ColumnHeader Icon is changed in Code

8. Looking for QBasic code for specific program....

9. Sort a grid(?) by pressing a columnheader

10. Get items from Listview sorted with API:s in sorted order

11. Bubble sort program code

12. Bubble sort program code

 

 
Powered by phpBB® Forum Software