Minggu, 14 Oktober 2012

Prosedur mengepaskan teks pada listview saat mode reportview



Public Sub ListviewSort(ByRef View As ListView, ByVal Column As Integer)
 
  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)
  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

0 komentar:

Posting Komentar

 

© 2011 e - Tutorial | by Moeh Fitrah