Ejemplo n.º 1
0
        private static void SendSetGroupInfo(LVGROUP group, ListViewGroup lstvwgrp)
        {
            int?grpId  = GetGroupID(lstvwgrp);
            int gIndex = lstvwgrp.ListView.Groups.IndexOf(lstvwgrp);

            IntPtr groupPtr = IntPtr.Zero;

            try
            {
                groupPtr = Marshal.AllocHGlobal(group.CbSize + 1);
                Marshal.StructureToPtr(group, groupPtr, false);

                if (grpId != null)
                {
                    group.IGroupId = grpId.Value;
                    WIN32.SendMessage(lstvwgrp.ListView.Handle, LVM_SETGROUPINFO, grpId.Value, groupPtr);
                }
                else
                {
                    group.IGroupId = gIndex;
                    WIN32.SendMessage(lstvwgrp.ListView.Handle, LVM_SETGROUPINFO, gIndex, groupPtr);
                }
            }
            catch (Exception err)
            {
                Debug.WriteLine("SendSetGroupInfo: " + err.Message);
            }
            finally
            {
                if (groupPtr != IntPtr.Zero)
                {
                    Marshal.FreeHGlobal(groupPtr);
                }
            }
        }
Ejemplo n.º 2
0
        private static bool PrepareSendHeader(ListViewGroup lstvwgrp, out LVGROUP group)
        {
            group = new LVGROUP();
            if (Environment.OSVersion.Version.Major < 6) //Only Vista and forward allows footer on ListViewGroups
            {
                return(false);
            }
            if (lstvwgrp == null || lstvwgrp.ListView == null)
            {
                return(false);
            }

            group.CbSize = Marshal.SizeOf(group);
            return(true);
        }