I am creating a 2D Map Editor in C#, And I've been trying to display objects in a ListView
, So it will look like this example (I'm not sure if the control in the example is an ListView. It might be something else):
But I can't seem to get there ! I'm using a ListView
with an imageList, the listView.View
is Tile
and I'm setting the ListViewItem's text.
That's how it looks (I've added one item)
I can't find a method to put the item's text BELOW the image and not next to it, like in the example.
Any thoughts on how I could do this?
TaW was certainly right with his answer, However, the problem with View=LargeIcon was that the spacing between items is too large, And I wanted to use View=Tile at first since there's no spacing between the items. So, after a little research I did about this, I came up with a solution for spacing, Which was a little altered by me.
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
private static extern Int32 SendMessage(IntPtr hwnd, Int32 wMsg, Int32 wParam, Int32 lParam);
const int LVM_FIRST = 0x1000;
const int LVM_SETICONSPACING = LVM_FIRST + 53;
public void SetControlSpacing(Control control, Int16 x, Int16 y)
{
SendMessage(control.Handle, LVM_SETICONSPACING, 0, x * 65536 + y);
control.Refresh();
}
And since the default spacing for a list control seems to be 100 (x), 100 (y), changing each to 75 has fixed the problem,
listView.View = View.largeIcon;
SetControlSpacing(listView, 75, 75);
And now looks like this:
Thanks for your help.