![]() ![]() The class library is an extract from a larger control library. The snippet above would produce something like: grouper.DisplayGroup += grouper_DisplayGroup void grouper_DisplayGroup( object sender, GroupDisplayEventArgs e)Į.BackColor = (e.Group.GroupIndex % 2) = 0 ? Color.Orange : Color.LightBlue Į.Header = ", grp: " + e.Group.GroupIndex Į.DisplayValue = " Value is " + e.DisplayValue Į.Summary = " contains " + e.Group.Count + " rows" The DisplayGroup event can be used to further customize whatever has to be shown: And a DisplayGroup event which is fired whenever one of the grouping rows is being painted. ![]() The component exposes a GroupingChanged event to catch when the grouping was changed or removed. default sort order for the groups is ascending, // you can change that in the options as well (ascending, descending or none) if you don't want the grouped column name to be repeated in the headers: if you don't want the (rowcount) to be shown in the headers: to collapse all loaded rows: (the difference with setting the option above, // is that after choosing a new grouping (or on a reload), the new groups would expand. If (args.RowIndex < 1 || args.ColumnIndex < 0)Ī = AdvancedCellBorderStyle.// to start with all rows collapsed on a (re)load or // when the group is changed you can set the option startcollapsed: Ignore column and row headers and first row (currCell.Value != null & prevCell.Value != null &Ĭ() = ()))ĭataGridViewAdvancedCellBorderStyle.None Private bool IsRepeatedCellValue(int rowIndex, int colIndex) ![]() If (IsRepeatedCellValue(args.RowIndex, args.ColumnIndex)) Protected override void OnCellFormatting(ĭataGridViewCellFormattingEventArgs args) The unmentioned idea is a class extending the DataGridView class. To supplement the (chosen) answer, here's the full code. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |