Пример #1
0
 private static void setGrpState(ListViewGroup lstvwgrp, ListViewGroupState state)
 {
     if (Environment.OSVersion.Version.Major < 6)               //Only Vista and forward
     // allows collapse of ListViewGroups
     {
         return;
     }
     if (lstvwgrp == null || lstvwgrp.ListView == null)
     {
         return;
     }
     if (lstvwgrp.ListView.InvokeRequired)
     {
         lstvwgrp.ListView.Invoke(new CallBackSetGroupState(setGrpState),
                                  lstvwgrp, state);
     }
     else
     {
         int?    GrpId  = GetGroupID(lstvwgrp);
         int     gIndex = lstvwgrp.ListView.Groups.IndexOf(lstvwgrp);
         LVGROUP group  = new LVGROUP();
         group.CbSize = Marshal.SizeOf(group);
         group.State  = state;
         group.Mask   = ListViewGroupMask.State;
         if (GrpId != null)
         {
             group.IGroupId = GrpId.Value;
             SendMessage(lstvwgrp.ListView.Handle,
                         LVM_SETGROUPINFO, GrpId.Value, group);
             SendMessage(lstvwgrp.ListView.Handle,
                         LVM_SETGROUPINFO, GrpId.Value, group);
         }
         else
         {
             group.IGroupId = gIndex;
             SendMessage(lstvwgrp.ListView.Handle, LVM_SETGROUPINFO, gIndex, group);
             SendMessage(lstvwgrp.ListView.Handle, LVM_SETGROUPINFO, gIndex, group);
         }
     }
 }
Пример #2
0
 private static extern int SendMessage
     (IntPtr hWnd, int Msg, int wParam, LVGROUP lParam);