I'm trying to sum the values in column 3 (Jobs) and 4 (Bids) in my listview PlotListView for a WPF application I am working on. This is what I've done so far:
C#
int jobSum = 0; int bidSum = 0; foreach (var item in PlotListView.ItemsSource) { jobSum += int.Parse(item.SubItems.Item(3)); bidSum += int.Parse(item.SubItems.Item(4)); } JobBidRatioTextBlock.Text = jobSum.ToString();
XAML
<ListView x:Name="PlotListView" HorizontalAlignment="Left" Height="228" Margin="5,37,0,0" VerticalAlignment="Top" Width="424"><ListView.View><GridView AllowsColumnReorder="False"><GridViewColumn Width="99" Header="Plot" DisplayMemberBinding="{Binding PlotId}"/><GridViewColumn Width="99" Header="Area" DisplayMemberBinding="{Binding Area}"/><GridViewColumn Width="99" Header="Jobs" DisplayMemberBinding="{Binding Jobs}"/><GridViewColumn Width="99" Header="Bids" DisplayMemberBinding="{Binding Bids}"/></GridView></ListView.View></ListView>
However, I am now seeing an issue where SubItems is not recognised.
Now I can't seem to figure out how to access the exact column - am I on the right track? What do I need to do?