.NET Framework - No replies re VirtualMode ListView controls

Asked By --
28-Dec-08 03:34 PM
No replies to the previous query. (Is no one using VirtualMode?)
The problem, again:

CheckBoxes don't appear when ListView controls are placed in
VirtualMode. They are 'there'...just not displayed. One 'user fix' was
posted on CodeProject; the ListView was set to owner draw, and the
checkboxes are checked, then unchecked. An odd thing to be forced to
do.

Unfortunately, the owner-draw fix causes headers to not be displayed
when in Details mode. Anyone know a simpler way to force checkboxes to
display without requiring owner-draw?

This does seem like a bug in ListView's VirtualMode. I can't imagine
any logical reason why checkboxes would not be displayed.
DrawListViewItemEventArgs
(1)
RetrieveVirtualItemEventHandler
(1)
RetrieveVirtualItemEventArgs
(1)
ListView
(1)
RetrieveVirtualItem
(1)
DrawItem
(1)
Report
(1)
SetupListview
(1)
  Peter Duniho replied...
28-Dec-08 07:26 PM
The only "previous query" I see, you sent only five minutes before the
message to which I'm replying.

I'm not sure what kind of forum you think this is, but you will find
people more interested in helping you if you can demonstrate more patience
than that.

As for the specific issue you're asking about, in nearly every case,
asking a question about why your code doesn't work without posting an
actual concise-but-complete code sample that reliably demonstrates the
problem isn't going to do you any good.  Your question here seems like a
perfect example of that.

So, if you want some help, please create a good, concise-but-complete code
example that reliably demonstrates the problem and post that along with
your question, including very specific information about what you expect
the code to do and what it does instead, as well as any instructions on
how to use the UI if appropriate.

Pete
  -- replied...
28-Dec-08 10:31 PM
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.
  Peter Duniho replied...
29-Dec-08 12:42 AM
For future reference, you can avoid confusing your readers by not starting
a brand-new thread for something that isn't a new topic.  Had you just
written a follow-up to your original post, it would have been clear to
which "previous query" you were referring.


You should consider the risks of making assumptions.

Beyond that, none of the code that the Designer generates is
to actually work.  If you leave the code out, then you are relying on
someone else to recreate from scratch the relevant code, which has _at
least_ two serious problems:

1) You are asking someone else to do the work that you should have
done yourself.
2) The other person may not even be able to reproduce your problem,
leading to answers like "you're doing something wrong...please post your
code".


Nothing is easier than copying and pasting code and compiling it.


You are posting to a C# newsgroup.  It's possible that had you picked a
newsgroup more specific to Forms programming, you could make the
assumption that your readers would be familiar with the problem (though,
see above my suggestion about the risks of making assumptions).  But here,
you are severely limiting your chances for getting a response if you
restrict those who can respond to those who have already seen the problem
you describe.

This newsgroup is primarily for questions about using the C# language.
Inasmuch as general Framework questions are tolerated, you cannot expect
there to be much broad expertise in specific topics, and should tailor
your questions accordingly, if you expect to get any useful replies at all
(and even then, you should be prepared to be met with silence...the more
esoteric the question, the less likely you'll get any useful replies).


If this is in fact an inherent bug in ListView, then posting here is
pointless.  Go to http://connect.microsoft.com/ and submit a bug report.
Microsoft generally responds to bug reports in a reasonably short period
of time (my experience has been generally a week or less), and can either
confirm whether the behavior you're seeing is a bug, or simply user error.

Pete
  ---- replied...
29-Dec-08 03:52 AM
On Sun, 28 Dec 2008 22:42:02 -0700, "Peter Duniho"


[rest snipped]

You know, Peter, you are generally helpful, and you're very good about
fielding tough questions here. So I was pleased to see your name on a
reply to my post.  But ironically, you have made the assumption that I
was posting complaints about no followups to a message 45 minutes
prior (which does indeed sound like a silly thing to do), and you've
gone on to base your scolding on that, That was incorrect, and I tried
to explain that politely.

So please -assume- that my original comment was truthful- I had posted
3 days ago, on Christmas day. No replies, and I thought it was logical
to split the two questions, as one could have been answered by someone
with no experience with VirtualMode. It really is as simple as that. I
was not getting impatient or demanding.


That was the intent, but I was not sure that it was indeed a bug.  I
do know that some knowledgable programmers have used VirtualMode and
posted about it here, so I thought it practical to pose the question
first.

Re 'pointless': There are often workarounds for known bugs, as in the
CodeProject article--it just didn't cover Details view. So I would not
consider the query pointless, unless it just results in more noise.
There really is no need for that.  I make no demands and have no
expectations of any posters. It was just an innocent technical
question. Let's leave it there.
  Peter Duniho replied...
29-Dec-08 10:49 AM
5 minutes prior, actually.  But yes, you are right...I made an incorrect
assumption and I'm sorry about that.  If anything, that should help you
see why it's so important to not make assumptions; learn from my mistake,
if not your own.

I provided advice as to how you can avoid confusing people to the extent
that they go on to make incorrect assumptions.  Perhaps you are choosing
to ignore that advice, but if nothing else you should be able to see the
danger in making assumptions.

As for your actual question (which you seem to have abandoned at this
point), my previous advice stands.

Pete
help
Library question .NET Framework I am getting these errors: DrawListViewItemEventArgs' could not be found DrawListViewSubItemEventArgs' could not be found DrawListViewColumnHeaderEventArgs' could not be found I clickedItem.Focused = true; } } / / Draws the backgrounds for entire ListView items. private void listView1_DrawItem(object sender, DrawListViewItemEventArgs e) { if ((e.State & ListViewItemStates.Selected) ! = 0) { / / Draw the background and focus rectangle for a all, VS2003 targets V1.x! Willy. keywords: Library, question description: I am getting these errors: DrawListViewItemEventArgs' could not be found DrawListViewSubItemEventArgs' could not be found DrawListViewColumnHeaderEventAr
one solve such problems TIA Barry .NET Framework Discussions Windows XP (1) LinearGradientMode.Horizontal (1) DrawListViewItemEventArgs (1) LinearGradientBrush (1) LinearGradientMode (1) ListView (1) Brushes.Maroon (1) FillRectangle (1) .NET does not in my app) / / Draws the backgrounds for entire ListView items. private void listView1_DrawItem(object sender, DrawListViewItemEventArgs e) { if ((e.State & ListViewItemStates.Selected) ! = 0) { / / Draw the background and focus rectangle for a
any event like this. Thank you for your help .NET WinForms Controls Discussions DrawListViewColumnHeaderEventArgs (1) DrawListViewItemEventArgs (1) ListView (1) Base.OnDrawColumnHeader (1) BackGroundStripe1Colour (1) BackGroundStripe2Colour (1) OnDrawColumnHeader (1) JListViewBase (1) On rour own class from a ListView and override the OnDrawItem event: protected override void OnDrawItem(DrawListViewItemEventArgs e) { if (m_BackGroundStripes) { if ((e.ItemIndex & 1) = = 0) { e.Item.BackColor = m_BackGroundStripe1Colour; } else { e.Item