c# - .NET ListView row padding -
there doesn't seem way change padding (or row height) rows in .net listview. have elegant hack-around?
i know post old, however, if never found best option, i've got blog post may help, involves utilizing lvm_seticonspacing.
according blog,
initially, you'll need add:
using system.runtime.interopservices;
next, you'll need import dll, can utilize sendmessage, modify listview parameters.
[dllimport("user32.dll")] public static extern int sendmessage(intptr hwnd, int msg, intptr wparam, intptr lparam);
once complete, create following 2 functions:
public int makelong(short lowpart, short highpart) { return (int)(((ushort)lowpart) | (uint)(highpart << 16)); } public void listviewitem_setspacing(listview listview, short leftpadding, short toppadding) { const int lvm_first = 0x1000; const int lvm_seticonspacing = lvm_first + 53; sendmessage(listview.handle, lvm_seticonspacing, intptr.zero, (intptr)makelong(leftpadding, toppadding)); }
then use function, pass in listview, , set values. in example, 64 pixels image width, , 32 pixels horizontal spacing/padding, 100 pixels image height, , 16 pixels vertical spacing/padding, , both parameters require minimum of 4 pixels.
listviewitem_setspacing(this.listview1, 64 + 32, 100 + 16);
Comments
Post a Comment