using System.Runtime.InteropServices;
using System.Windows.Forms;

namespace CETEST
{
    public class Common
    {

        private const int LVM_GETEXTENDEDLISTVIEWSTYLE = 0x1037;
        private const int LVM_SETEXTENDEDLISTVIEWSTYLE = 0x1036;
        private const int LVS_EX_GRIDLINES = 0x1;

        [DllImport("coredll.dll")]
        private static extern int SendMessageW(int hWnd, int wMsg, int wParam, int lParam);

        [DllImport("coredll.dll")]
        private static extern int GetFocus();

        public static void SetGridLines(ListView lvw)        {
            lvw.Focus();
            int hWnd = GetFocus();
            int extendedStyle = SendMessageW(hWnd, LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0);
            extendedStyle |= LVS_EX_GRIDLINES;
            SendMessageW(hWnd, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, extendedStyle);
        }
    }
}

 

相关文章:

  • 2021-08-09
  • 2021-12-30
  • 2021-08-06
  • 2021-06-29
  • 2021-10-18
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-01-23
  • 2022-12-23
  • 2021-08-09
  • 2022-12-23
  • 2021-06-22
  • 2022-12-23
相关资源
相似解决方案