Beispiel #1
0
 /// <summary>
 /// Set group footer.
 /// </summary>
 /// <param name="lstvwgrp"></param>
 /// <param name="footer"></param>
 private static void SetGrpFooter(ListViewGroup lstvwgrp, string footer)
 {
     if (Environment.OSVersion.Version.Major < 6)   //Only Vista and forward allows footer on ListViewGroups
     {
         return;
     }
     if (lstvwgrp == null || lstvwgrp.ListView == null)
     {
         return;
     }
     if (lstvwgrp.ListView.InvokeRequired)
     {
         lstvwgrp.ListView.Invoke(new CallbackSetGroupString(SetGrpFooter), lstvwgrp, footer);
     }
     else
     {
         int?    GrpId  = GetGroupID(lstvwgrp);
         int     gIndex = lstvwgrp.ListView.Groups.IndexOf(lstvwgrp);
         LVGROUP group  = new LVGROUP();
         group.CbSize    = Marshal.SizeOf(group);
         group.PszFooter = footer;
         group.Mask      = ListViewGroupMask.Footer;
         if (GrpId != null)
         {
             group.IGroupId = GrpId.Value;
             SendMessage(lstvwgrp.ListView.Handle, LVM_SETGROUPINFO, GrpId.Value, group);
         }
         else
         {
             group.IGroupId = gIndex;
             SendMessage(lstvwgrp.ListView.Handle, LVM_SETGROUPINFO, gIndex, group);
         }
     }
 }
Beispiel #2
0
 /// <summary>
 /// Set group state.
 /// </summary>
 /// <param name="lstvwgrp"></param>
 /// <param name="state"></param>
 private static void SetGrpState(ListViewGroup lstvwgrp, ListViewGroupState state)
 {
     if (Environment.OSVersion.Version.Major < 6)   //Only Vista and forward allows collaps 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);
         }
         lstvwgrp.ListView.Refresh();
     }
 }
Beispiel #3
0
 private static extern int SendMessage(IntPtr hWnd, int uMsg, int wParam, LVGROUP lParam);