I have played a little around with a ListView and here is the easiest way
for you to change background / foreground colors by means of P/Invoking to
the underlying Win32 ListView control. What you can do best is download the
WinAPI library from OpenNETCF.org (
http://www.opennetcf.org/winapi.asp).
Amongst others it contains functions to P/Invoke into the native Win32 code
and that is what you need to change colors of your ListView. In a little
sample I created a simple ListView control and a button on a form. When the
button is clicked I want to change the backcolor of the ListView. I hope
that you get the idea, even though the sample is in C#, not in VB:
private void button1_Click(object sender, System.EventArgs e)
{
listView1.Capture = true; // The
first 3 statements are used to get the handle to the ListView window.
IntPtr hWnd = Win32Window.GetCapture();
listView1.Capture = false;
Win32Window.SendMessage(hWnd, (uint)ListViewMessage.LVM_SETBKCOLOR , 0,
0x00ff0000); // Once we have a Window handle, we can now send the
ListView messages, like this one to change the background color.
listView1.Invalidate();
}
}
public enum ListViewMessage: uint // These are the WIndows messages as
defined in commctrl.h to "talk" to the ListView
{
LVM_FIRST = 0x1000,
LVM_GETBKCOLOR = LVM_FIRST + 0,
LVM_SETBKCOLOR = LVM_FIRST + 1,
LVM_GETTEXTCOLOR = LVM_FIRST + 35,
LVM_SETTEXTCOLOR = LVM_FIRST + 36,
LVM_GETTEXTBKCOLOR = LVM_FIRST + 37,
LVM_SETTEXTBKCOLOR = LVM_FIRST + 38,
}