private static void setGrpState(ListViewGroup listViewGroup, ListViewGroupState state) { if (Environment.OSVersion.Version.Major < 6) //Only Vista and forward // allows collapse of ListViewGroups { return; } if (listViewGroup == null || listViewGroup.ListView == null) { return; } if (listViewGroup.ListView.InvokeRequired) { listViewGroup.ListView.Invoke(new CallBackSetGroupState(setGrpState), listViewGroup, state); } else { int? groupId = GetGroupID(listViewGroup); int gIndex = listViewGroup.ListView.Groups.IndexOf(listViewGroup); LVGROUP group = new LVGROUP(); group.CbSize = Marshal.SizeOf(group); group.State = state; group.Mask = ListViewGroupMask.State; if (groupId != null) { group.IGroupId = groupId.Value; SendMessage(listViewGroup.ListView.Handle, LVM_SETGROUPINFO, groupId.Value, group); SendMessage(listViewGroup.ListView.Handle, LVM_SETGROUPINFO, groupId.Value, group); } else { group.IGroupId = gIndex; SendMessage(listViewGroup.ListView.Handle, LVM_SETGROUPINFO, gIndex, group); SendMessage(listViewGroup.ListView.Handle, LVM_SETGROUPINFO, gIndex, group); } listViewGroup.ListView.Refresh(); } }
private static void setGroupFooter(ListViewGroup listViewGroup, string footer) { if (Environment.OSVersion.Version.Major < 6) //Only Vista and forward //allows footer on ListViewGroups { return; } if (listViewGroup == null || listViewGroup.ListView == null) { return; } if (listViewGroup.ListView.InvokeRequired) { listViewGroup.ListView.Invoke(new CallbackSetGroupString(setGroupFooter), listViewGroup, footer); } else { int? GrpId = GetGroupID(listViewGroup); int gIndex = listViewGroup.ListView.Groups.IndexOf(listViewGroup); LVGROUP group = new LVGROUP(); group.CbSize = Marshal.SizeOf(group); group.PszFooter = footer; group.Mask = ListViewGroupMask.Footer; if (GrpId != null) { group.IGroupId = GrpId.Value; SendMessage(listViewGroup.ListView.Handle, LVM_SETGROUPINFO, GrpId.Value, group); } else { group.IGroupId = gIndex; SendMessage(listViewGroup.ListView.Handle, LVM_SETGROUPINFO, gIndex, group); } } }
private static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, LVGROUP lParam);
private static void setGrpState(ListViewGroup listViewGroup, ListViewGroupState state) { if (Environment.OSVersion.Version.Major < 6) //Only Vista and forward // allows collapse of ListViewGroups return; if (listViewGroup == null || listViewGroup.ListView == null) return; if (listViewGroup.ListView.InvokeRequired) listViewGroup.ListView.Invoke(new CallBackSetGroupState(setGrpState), listViewGroup, state); else { int? groupId = GetGroupID(listViewGroup); int gIndex = listViewGroup.ListView.Groups.IndexOf(listViewGroup); LVGROUP group = new LVGROUP(); group.CbSize = Marshal.SizeOf(group); group.State = state; group.Mask = ListViewGroupMask.State; if (groupId != null) { group.IGroupId = groupId.Value; SendMessage(listViewGroup.ListView.Handle, LVM_SETGROUPINFO, groupId.Value, group); SendMessage(listViewGroup.ListView.Handle, LVM_SETGROUPINFO, groupId.Value, group); } else { group.IGroupId = gIndex; SendMessage(listViewGroup.ListView.Handle, LVM_SETGROUPINFO, gIndex, group); SendMessage(listViewGroup.ListView.Handle, LVM_SETGROUPINFO, gIndex, group); } listViewGroup.ListView.Refresh(); } }
private static void setGroupFooter(ListViewGroup listViewGroup, string footer) { if (Environment.OSVersion.Version.Major < 6) //Only Vista and forward //allows footer on ListViewGroups return; if (listViewGroup == null || listViewGroup.ListView == null) return; if (listViewGroup.ListView.InvokeRequired) listViewGroup.ListView.Invoke(new CallbackSetGroupString(setGroupFooter), listViewGroup, footer); else { int? GrpId = GetGroupID(listViewGroup); int gIndex = listViewGroup.ListView.Groups.IndexOf(listViewGroup); LVGROUP group = new LVGROUP(); group.CbSize = Marshal.SizeOf(group); group.PszFooter = footer; group.Mask = ListViewGroupMask.Footer; if (GrpId != null) { group.IGroupId = GrpId.Value; SendMessage(listViewGroup.ListView.Handle, LVM_SETGROUPINFO, GrpId.Value, group); } else { group.IGroupId = gIndex; SendMessage(listViewGroup.ListView.Handle, LVM_SETGROUPINFO, gIndex, group); } } }