Initial
This commit is contained in:
57
EDOKA/Drucken/clsListViewItemComparer.vb
Normal file
57
EDOKA/Drucken/clsListViewItemComparer.vb
Normal file
@@ -0,0 +1,57 @@
|
||||
Public Class clsListViewItemComparer
|
||||
|
||||
Implements IComparer
|
||||
|
||||
Private _Column As Integer
|
||||
Private _Numeric As Boolean = False
|
||||
|
||||
Public Property Column() As Integer
|
||||
Get
|
||||
Return _Column
|
||||
End Get
|
||||
Set(ByVal Value As Integer)
|
||||
_Column = Value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Public Property Numeric() As Boolean
|
||||
Get
|
||||
Return _Numeric
|
||||
End Get
|
||||
Set(ByVal Value As Boolean)
|
||||
_Numeric = Value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Public Sub New(ByVal ColumnIndex As Integer)
|
||||
Column = ColumnIndex
|
||||
End Sub
|
||||
|
||||
Public Function Compare(ByVal x As Object, ByVal y As Object) As Integer _
|
||||
Implements System.Collections.IComparer.Compare
|
||||
Dim ListX As ListViewItem = CType(x, ListViewItem)
|
||||
Dim ListY As ListViewItem = CType(y, ListViewItem)
|
||||
If Numeric Then
|
||||
Dim ListXVal, ListYVal As Decimal
|
||||
Try
|
||||
ListXVal = Decimal.Parse(ListX.SubItems(Column).Text)
|
||||
Catch
|
||||
ListXVal = 0
|
||||
End Try
|
||||
Try
|
||||
ListYVal = Decimal.Parse(ListY.SubItems(Column).Text)
|
||||
Catch
|
||||
ListYVal = 0
|
||||
End Try
|
||||
|
||||
Return Decimal.Compare(ListXVal, ListYVal)
|
||||
Else
|
||||
Dim ListXText As String = ListX.SubItems(Column).Text
|
||||
Dim ListYText As String = ListY.SubItems(Column).Text
|
||||
|
||||
Return String.Compare(ListXText, ListYText)
|
||||
End If
|
||||
|
||||
End Function
|
||||
|
||||
End Class
|
||||
Reference in New Issue
Block a user