ListView items margin RRS feed

  • Question

  • Hello,

    I have a problem with my listView control.
    I am using the LargeIcon view and the spacing between each item (from all sides) is hardcoded (I think).
    There is no way to change it (at least not from a property).

    Can anyone think of a way to solve this problem?

    I am using Framework 2.0.

    Thank you

    Sunday, July 8, 2007 6:54 AM


  • You can do this by sending a message to the ListView:

        public void SetIconSpacing(int hor, int ver) {
          hor += listView1.LargeImageList.ImageSize.Width;
          ver += listView1.LargeImageList.ImageSize.Height;   // Should include space for label!
          int lp = (ver << 16) + hor;
          SendMessage(listView1.Handle, 0x1000 + 53, IntPtr.Zero, (IntPtr)lp);
        private static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wp, IntPtr lp);

    Sunday, July 8, 2007 4:54 PM