I'm attempting to produce a listview that I can use with my dataset that when a column in my dataset has a value of say "complete" will show that specific ROW a different color than the rest of the rows in the listview allowing for easier readability for the user.
I'm thinking about looping the data from my dataset to the listview's collection and then running logic on the items after the items populate when the control is loaded, would this be best or is there some other way I could do this using binding or without extracting the dataset??
Heres my code so far?
XAML
P.S I'm also having a blonde moment on how to loop my dataset to the listview control...
I'm thinking about looping the data from my dataset to the listview's collection and then running logic on the items after the items populate when the control is loaded, would this be best or is there some other way I could do this using binding or without extracting the dataset??
Heres my code so far?
Private Sub loadtasks()
lv1.DataContext = Nothing
Dim cmd As SqlCommand
Dim sql As String = "Select ID, Priority, Description, Status, Show from Tasks"
Dim dstasks As New DataSet
cmd = New SqlCommand(sql, constr)
Dim adapter As New SqlDataAdapter()
adapter.SelectCommand = cmd
adapter.Fill(dstasks, "Tasks1")
'lv1.DataContext = dstasks
'loop would go here
For Each lvi As ListViewItem In lv1.Items
If lvi.Content = "Completed" Then
lvi.Foreground = Brushes.Gray
End If
Next
XAML
<ListView x:Name="lv1" AlternationCount="2" HorizontalAlignment="Left" Height="787" VerticalAlignment="Top" Width="648" Margin="121,104,0,0"
ItemsSource="{Binding}" SelectionMode="Single" ScrollViewer.HorizontalScrollBarVisibility="Disabled">
<ListView.View>
<GridView AllowsColumnReorder="False">
<GridViewColumn Header="Priority"
Width="60"
DisplayMemberBinding="{Binding Path=Priority}"/>
<GridViewColumn Header="Description"
Width="450"
DisplayMemberBinding="{Binding Path=Description}"/>
<GridViewColumn Header="Status"
Width="133"
DisplayMemberBinding="{Binding Path=Status}"/>
</GridView>
</ListView.View>
</ListView>
P.S I'm also having a blonde moment on how to loop my dataset to the listview control...