ListView 的 View 設定為 LargeIcon 時,ICON 之間內定的距離是沒辦法透過設定來縮小的.
找了一陣子才發現,可以透過這個 Function 來修改內定的距離.

using System.Runtime.InteropServices;

/// <summary>
/// 控制ListView項之間的距離
/// </summary>
/// <param name="Handle"></param>
/// <param name="wMsg"></param>
/// <param name="wParam">水平間距</param>
/// <param name="lParam">垂直間距</param>
/// <returns></returns>
[DllImport("User32.dll")]
private static extern int SendMessage(int Handle, int wMsg, int wParam, int lParam);

const int LVM_FIRST = 0x1000;
const int LVM_SETICONSPACING = LVM_FIRST + 53;

public static void SetListViewSpacing(ListView lst, int x, int y)
{
    SendMessage(lst.Handle.ToInt32(), LVM_SETICONSPACING, 0, x * 65536 + y);
}

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 基因 的頭像
    基因

    老骨頭先生

    基因 發表在 痞客邦 留言(0) 人氣()