
On Sun, 28 Dec 2008 17:26:31 -0700, "Peter Duniho"
Peter, I posted the question three days ago. ("No checkboxes for
Virtual ListViews" or something like that.) That's why I said there
were no replies...usually three days means it wasn't noticed and isn't
going to be.
My other more recent post was in regard to drawing headers for
owner-drawn Listboxes, which relates to regular listboxes as well as
VirtualMode. Related, but different question (see below).
I use the forms designer, which generates a lot of extraneous code, so
I thought that posting all of that would be extravagant for a problem
that (I assume) is known.
As the concept is very simple, it's easier to just explain it. Anyone
who has used virtual mode well enough to answer this already knows the
drill: If you drag a ListView to a form and set CheckBoxes and
VirtualMode, the checkboxes don't appear.
This article on CodeProject explains it:
http://www.codeproject.com/KB/list/ListViewVirtualMode.aspx
From the article:
void SetupListview(bool blnVirtual)
{
...
this.listView1.VirtualMode = true;
this.listView1.RetrieveVirtualItem +=
new
RetrieveVirtualItemEventHandler(listView_RetrieveVirtualItem);
...
}
void listView_RetrieveVirtualItem(object sender,
RetrieveVirtualItemEventArgs e)
{
// e contains ItemIndex
e.Item = listViewItem;
}
Unfortunately, the article doesn't address Details view, in which the
header comes into play. Hence the tangential query: If I can get
checkboxes to show up without setting owner-draw, then the problem is
solved.
But if that's an inherent bug in ListView (?) then I'd need to use
owner-draw, in which case the header doesn't get displayed (at least
with the simple code-fragment that I had posted).
The latter occurs even with non-VirtualMode ListViews, so again, it's
just a matter of dragging a ListView and setting OwnerDraw and
Details, with the other code fragment that I had already posted:
void listView_DrawItem(object sender, DrawListViewItemEventArgs e)
{
e.DrawDefault = true;
}
I trust that explains things a bit better. Thanks for your patience.