Nabend,
Weiß jemand wie ich eine Bindinglist(Meine Klasse) nach einer Property sortieren/ordnen ?
Die Property ist eine Double.
0,32
-0,57
0,78
Soll so sortiert sein
0,78
-0,57
0,32
Quasi ohne Vorzeichen abwärts (Math.abs)
Weiß jemand wie ich eine Bindinglist(Meine Klasse) nach einer Property sortieren/ordnen ?
Die Property ist eine Double.
0,32
-0,57
0,78
Soll so sortiert sein
0,78
-0,57
0,32
Quasi ohne Vorzeichen abwärts (Math.abs)
Visual Basic-Quellcode
- Imports System.ComponentModel
- Public Class Form1
- Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
- Dim BList As New BindingList(Of Testklasse)
- BList.Add(New Testklasse With {.Wert = 0.32, .Name = "A"})
- BList.Add(New Testklasse With {.Wert = -0.57, .Name = "B"})
- BList.Add(New Testklasse With {.Wert = 0.78, .Name = "C"})
- ' BList.OrderByDescending(Function(x) Math.Abs(x.Wert))
- DataGridView1.DataSource = BList
- End Sub
- End Class
- Public Class Testklasse
- Public Property Wert As Double
- Public Property Name As String
- End Class
In Arbeit...