???? ????? ??? Visual Basic 2005 ?? Visual Basic .NET ??? ?? ?? ListView ???????? ?? ????? ???? ?? ??? ???? ????

???? ?????? ???? ??????
???? ID: 319399 - ?? ???????? ?? ?????? ??? ?? ?? ???? ???? ???? ??.
?? Microsoft Visual C# .NET ??????? ?? ??? ?? ???? ??, ?????319401.
?? ???? ?? Microsoft Visual Basic 6.0 ??????? ?? ???, ?????170884.
??? ?? ??????? ???? | ??? ?? ??????? ????

?? ????? ??

??????

?? ??? ?? ??? ???? ????? ?? ?? ???? ????? ???? ?? ??? ??????? ?????Visual Basic .NET ?? Visual Basic 2005 ????????? ??? ???? ????? ?????? ????????? ?????

?? ?? ??? ??????? ????????????? ?? ???, ?? ???? ?? ?? ???? ??????? ?? ???? ??????? ????? ?? ???? ?? ????? ????? ?? ?????? ?? ???????????? ?? ?? ?????? Windows Explorer ????????? ??? ??????? ???? ?? ?? ?? ??????? ?? ??????? ?? ????? ????? ?? ????? ???.. ????? ????? ???, Windows Explorer ?? ??????? ??? ????? ??????? ?? ???? ??? ??????? ????????? ???? ??.. ?????? ?? ???, ?? ????? ??? ????? ?? ???, ????? ?? ????, ????? ?? ??????, ?? ?? ?????? ?? ????? ??????? ??? ??.. ?? ?? ???? ????? ???????? ?? ????? ???? ???, ?? ?? ????? ?? ???? ?? ????? ???? ??? ???? ????? ???? ??.. ?? ?? ??? ????? ???????? ?? ??? ?? ????? ???? ???, ?? ????? ???? ???? ??? ????? ???? ??..

?? ???? ??? ?????? ???? ???? ?? ?? ?? ????? ?? ???????? ???? ??IComparer???????? ??? ??? ??, ?? ?????? ????? ???? ???? ????? ?????? ??? ????CaseInsenstiveComparer???? ?? ?????? ?? ???????? ????? ???? ?? ??? ??? ????? ??? ?? ????? ???? ?? ?? ???? ??? ?????? ???? ?? ("Apple" ?? "apple" ?? ???? ?? ???? ???? ??).. ?? ?? ????? ??? ?? ?? ?????? ?? ??? ????? "???" ?? ??? ????? ??? ???? ???.. ??? ?? ??? ??? ?? ????? ???? ????? ??? (???? ???????? ??? ???), ?? ?? ????? ??? ?? ?????? ?? ????? ???? ?? ?? ????? ?? ?????? ????? ??? ???? ???????????? ?? ???? ???::
compareResult = ObjectCompare.Compare(listviewX.SubItems(ColumnToSort).Text, listviewY.SubItems(ColumnToSort).Text)
				

????? ????????? ???? ?????

  1. ??? ??? Visual Basic .NET ?? 2005 Windows ????????? Visual Basic ????????? ?????? Form1 ???????? ??? ?? ???? ??..

    ???:?? Visual Basic 2005 ??? ??? ?? ????????? ???? ?????? ??? ???????? ??? ??, Visual Basic ????? ????? ??????? ?? ????????? ?? ??? ?? ?? ?? Windows ??????? ????????? ????? ???? ??? ?????? ?? Form1 ??? ??, ??????? ?? ???????????? ???? ???? ?? ??????? Form1.vb ?? Form1.Designer.vb ??? ???? Form1.vb ????? ??? ??? ?????? Windows ??????? ??????? Form1.Designer.vb ????? ??? ??? ????? ??? Form1 ?? ??????????? ?? ?? ??? ??????? ??? ??????? ???? ?? ??? Windows ??????? ??????? ????? ?????? ?? ????? ???? ??? ?? ??????? designer-????? ???? ??? ??? ?? ???? ??? ?? ??? interspersed ?? ????? ???

    Visual Basic 2005 ?? ?? ???? ????????????? ?? ???? ??? ???? ??????? ?? ??? ????? Microsoft ?????? ??????? (MSDN) ??? ???? ?? ????:
    (vs.80) http://msdn2.Microsoft.com/en-us/library/ms379584 .aspx
    ????? ???? ?? Windows ??????? ??????? ?? ???? ??? ???? ??????? ?? ??? ????? MSDN ??? ???? ?? ????:
    HTTP://msdn2.Microsoft.com/en-us/library/ms171843.aspx
  2. ????? ??????? ?????Form1 ????????? ????? ?????? ?? ??? ??? ????? ?? ??? ??? ???? ?????..
  3. ?????? ?? ??? ????? ??? ????? ??? ???????::
    Private lvwColumnSorter As ListViewColumnSorter
    					
  4. ??? ???? ?? ??? constructor ?? ??? ??? ????? ??? ???????InitializeComponent????:
    ' Create an instance of a ListView column sorter and assign it 
    ' to the ListView control.
    lvwColumnSorter = New ListViewColumnSorter()
    Me.ListView1.ListViewItemSorter = lvwColumnSorter
    					
  5. ??? ????? ??? ?????????? ????????? ?? ???????:
    Dim columnheader As ColumnHeader    ' Used for creating column headers.
    Dim listviewitem As ListViewItem    ' Used for creating ListView items.
    
    ' Make sure that the view is set to show details.
    ListView1.View = View.Details
    
    ' Create some ListView items consisting of first and last names.
    listviewitem = New ListViewItem("Mike")
    listviewitem.SubItems.Add("Nash")
    Me.ListView1.Items.Add(listviewitem)
    
    listviewitem = New ListViewItem("Kim")
    listviewitem.SubItems.Add("Abercrombie")
    Me.ListView1.Items.Add(listviewitem)
    
    listviewitem = New ListViewItem("Sunil")
    listviewitem.SubItems.Add("Koduri")
    Me.ListView1.Items.Add(listviewitem)
    
    listviewitem = New ListViewItem("Birgit")
    listviewitem.SubItems.Add("Seidl")
    Me.ListView1.Items.Add(listviewitem)
    
    ' Create some column headers for the data.
    columnheader = New ColumnHeader()
    columnheader.Text = "First Name"
    Me.ListView1.Columns.Add(columnheader)
    
    columnheader = New ColumnHeader()
    columnheader.Text = "Last Name"
    Me.ListView1.Columns.Add(columnheader)
    
    ' Loop through and size each column header to fit the column header text.
    For Each columnheader In Me.ListView1.Columns
        columnheader.Width = -2
    Next
    					
  6. ??? ????? ??? ???????ColumnClick?? ??? ????????? ?????:
    ' Determine if the clicked column is already the column that is 
    ' being sorted.
    If (e.Column = lvwColumnSorter.SortColumn) Then
        ' Reverse the current sort direction for this column.
        If (lvwColumnSorter.Order = SortOrder.Ascending) Then
            lvwColumnSorter.Order = SortOrder.Descending
        Else
            lvwColumnSorter.Order = SortOrder.Ascending
        End If
    Else
        ' Set the column number that is to be sorted; default to ascending.
        lvwColumnSorter.SortColumn = e.Column
        lvwColumnSorter.Order = SortOrder.Ascending
    End If
    
    ' Perform the sort with these new sort options.
    Me.ListView1.Sort()
    					
  7. ????? ????????????????? ??,????? ??????????????? ?? ??? ?? ??? ???? ???????
  8. ?? ????? ?? ???? ??????? ??? ?? ????? ??? ?? ???????????? ????::
    Imports System.Collections
    Imports System.Windows.Forms
    
    Public Class ListViewColumnSorter
        Implements System.Collections.IComparer
    
        Private ColumnToSort As Integer
        Private OrderOfSort As SortOrder
        Private ObjectCompare As CaseInsensitiveComparer
    
        Public Sub New()
            ' Initialize the column to '0'.
            ColumnToSort = 0
    
            ' Initialize the sort order to 'none'.
            OrderOfSort = SortOrder.None
    
            ' Initialize the CaseInsensitiveComparer object.
            ObjectCompare = New CaseInsensitiveComparer()
        End Sub
    
        Public Function Compare(ByVal x As Object, ByVal y As Object) As Integer Implements IComparer.Compare
            Dim compareResult As Integer
            Dim listviewX As ListViewItem
            Dim listviewY As ListViewItem
    
            ' Cast the objects to be compared to ListViewItem objects.
            listviewX = CType(x, ListViewItem)
            listviewY = CType(y, ListViewItem)
    
            ' Compare the two items.
            compareResult = ObjectCompare.Compare(listviewX.SubItems(ColumnToSort).Text, listviewY.SubItems(ColumnToSort).Text)
    
            ' Calculate the correct return value based on the object 
            ' comparison.
            If (OrderOfSort = SortOrder.Ascending) Then
                ' Ascending sort is selected, return typical result of 
                ' compare operation.
                Return compareResult
            ElseIf (OrderOfSort = SortOrder.Descending) Then
                ' Descending sort is selected, return negative result of 
                ' compare operation.
                Return (-compareResult)
            Else
                ' Return '0' to indicate that they are equal.
                Return 0
            End If
        End Function
    
        Public Property SortColumn() As Integer
            Set(ByVal Value As Integer)
                ColumnToSort = Value
            End Set
    
            Get
                Return ColumnToSort
            End Get
        End Property
    
        Public Property Order() As SortOrder
            Set(ByVal Value As SortOrder)
                OrderOfSort = Value
            End Set
    
            Get
                Return OrderOfSort
            End Get
        End Property
    End Class
    					
  9. ??????, ?????, ?? ???? ??? ????? ????????? ?? ?????..
  10. ??? ??????? ????? ????? ????? ???????? ????????????? ??? ?? ?? ????????, ?? ??????? ????????? ????????????? ????? ????? ??? ?? ????? ?? ???? ?? ???? ??? ????? ?? ?? ???? ?? ?? ??? ????? ???????? ?? ??? ?? ????? ???? ???, ?? ????? ???? ???? ??? ????? ???? ??..

???

???? ID: 319399 - ????? ???????: 03 ?????? 2010 - ??????: 2.0
???? ???? ???? ??:
  • Microsoft Visual Basic 2005
  • Microsoft Visual Basic .NET 2003 Standard Edition
  • Microsoft Visual Basic .NET 2002 Standard Edition
??????: 
kbvs2005swept kbvs2005applies kbhowtomaster kbmt KB319399 KbMthi
???? ?????? ????????
??????????: ?? ???? ?? ???? ??????? ?? ????? ?? Microsoft ????-?????? ?????????? ?????? ?????? ???? ??? ??. Microsoft ???? ??? ????-???????? ?? ????-???????? ????? ?????? ?? ???? ???????? ???? ?? ???? ????? ????? ??? ?? ??? ?????? ?? ???? ???? ???? ??? ????? ??. ???????, ????-???????? ???? ????? ???? ???? ???? ???. ?????, ????????, ?????-???? ?? ??????? ?? ???????? ?? ???? ???, ???? ?? ??? ?????? ???? ???? ??? ????? ??? ?? ???? ??. Microsoft ??????? ??? ???? ?? ?????? ?? ??????????, ????????? ?? ??? ?????? ?? ???? ????? ?? ???? ???????? ?? ??? ???? ????? ?? ??? ????????? ???? ??. Microsoft ????-?????? ?????????? ?? ????? ?????? ?? ?? ??? ??.
?????????? ?? ??????? ????????? ??????? ??:319399

??????????? ???

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com