Procedures to autofit text into a listview (reportview) control and to sort a listview by column.
Procedures to autofit text into a listview (reportview) control and to sort a listview by column.
API Declarations
Rate Procedures to autofit text into a listview (reportview) control and to sort a listview by column.
(1(1 Vote))
'Name: ListView procedures
'
'Author: Ralph Ligtenberg ([email protected])
'Copyright: 2000, Wortell
'
'Modified: 2000-05-31
'
'Description: Contains procedures to manipulate ListViews.
'
'Usage: See procedures for more details.
Public Sub ListviewSort(ByRef View As ListView, ByVal Column As Integer)
'Sorts the list depending on specified column
If View.SortKey <> Column - 1 Then
View.ColumnHeaders(View.SortKey + 1).Text = _
Left(View.ColumnHeaders(View.SortKey + 1).Text, 1) _
& LCase(Mid(View.ColumnHeaders(View.SortKey + 1).Text, 2))
View.ColumnHeaders(Column).Text = UCase(View.ColumnHeaders(Column).Text)
View.SortKey = Column - 1
End If
End Sub
Public Sub ListviewAutoFit(ByRef List As ListView, _
ByRef AutosizeLabel As Label)
'Automatically resizes listview columns so that all text
'is visible. If the column name is empty, the column will
'be resized to 0.
'To make this procedure work properly, AutosizeLabel must
'have the following settings:
' - Font has to be the same as the Listview's
' - Visible = False
' - AutoSize = True
Dim i As Long
Dim j As Long
Dim State As Boolean
With List
State = .Visible
.Visible = False
For i = 1 To .ColumnHeaders.Count
If .ColumnHeaders(i).Text <> "" Then
AutosizeLabel.Caption = .ColumnHeaders(i).Text
.ColumnHeaders(i).Width = AutosizeLabel.Width + 280
For j = 1 To .ListItems.Count
If i = 1 Then
AutosizeLabel.Caption = .ListItems(j) _
& IIf(.Icons Is Nothing, "", "XX")
Else
AutosizeLabel.Caption = .ListItems(j).SubItems(i - 1)
End If
If .ColumnHeaders(i).Width < AutosizeLabel.Width + 280 Then
.ColumnHeaders(i).Width = AutosizeLabel.Width + 280
End If
Next
Else
.ColumnHeaders(i).Width = 0
End If
Next
.Visible = State
End With
End Sub
Procedures to autofit text into a listview (reportview) control and to sort a listview by column. Comments
No comments yet — be the first to post one!
Post a Comment