Hello Everyone:
I am trying to figure out how to dynamically add Groups to a list view. But the grouping isn't working. Specifically all the line details spreads across the every other row in the group, starting with the first row: Following is the applicable script:
conn.Open(); // ====================== TESTING: Total Counts by Rank/Shift/Station ================== var cmd_StationCts = conn.CreateCommand(); cmd_StationCts.CommandText = "SELECT (CASE WHEN StationAssignment = '' Then 'UA' ELSE StationAssignment END) as Station, RankClr, Rank, SUM((CASE WHEN Shift = '' THEN 1 ELSE 0 END)) AS U, SUM((CASE WHEN Shift = 'A' THEN 1 ELSE 0 END)) AS A, SUM((CASE WHEN Shift = 'B' THEN 1 ELSE 0 END)) AS B, COUNT(PersonnelID) AS RankTotals FROM Personnel_Tbl GROUP BY RankClr, Rank, RankOrder, StationAssignment ORDER BY StationAssignment, RankOrder"; SqlCeDataReader dr = cmd_StationCts.ExecuteReader(); // This for Loop creates the headings. for (int i = 0; i < dr.FieldCount; i++) { ColumnHeader ch = new ColumnHeader(); ch.Text = dr.GetName(i); StationCTs_ListVW.Columns.Add(ch); } // Trying to build list and do the grouping here while (dr.Read()) { ListViewItem lvi = StationCTs_ListVW.Items.Add(dr.GetValue(0).ToString()); for (int i = 1; i < dr.FieldCount; i++) { lvi.SubItems.Add(dr.GetValue(i).ToString()); } StationCTs_ListVW.Items.Add(dr.GetValue(0).ToString()); }
Any assistance is appreciated - thanks in advance:
Pavilion