I have a ListView
where I add as Items
some ListViewItem
s. The View
property is set to Details
. When the ListView
is displayed the ListViewItem
s haven't any border (top and bottom line that separates one item from another).
How can I do to add a border to all my items?
An example:
For whatever reason, Gridlines aren't supported by the CF control, though the underlying native ListView does. P/Invoke to the rescue.
private const uint LVM_FIRST = 0x1000;
private const uint LVM_SETEXTENDEDLISTVIEWSTYLE = LVM_FIRST + 54;
private const uint LVM_GETEXTENDEDLISTVIEWSTYLE = LVM_FIRST + 55;
private const uint LVS_EX_GRIDLINES = 0x00000001;
[DllImport("coredll.dll")]
private static extern uint SendMessage(IntPtr hwnd, uint msg, uint wparam, uint lparam);
public void EnableGridlines(ListView listView)
{
var style = SendMessage(
listView.Handle,
LVM_GETEXTENDEDLISTVIEWSTYLE,
0,
0);
style |= LVS_EX_GRIDLINES;
var style = SendMessage(
listView.Handle,
LVM_SETEXTENDEDLISTVIEWSTYLE,
0,
style);
}
ListView doesn't support GridLines in compact framework. You can use DataGridView
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With