By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,068 Members | 825 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,068 IT Pros & Developers. It's quick & easy.

OwnerDraw ListView subitem problems

P: n/a
Hi All,

I have an ownerdraw ListView control.
I'm trying to use an ownerdrawn ListView control to draw and display images in the second column of
a listview which is set to detail view.

I have overridden the DrawColumnHeader, DrawItem, DrawSubItem methods as displayed below.
It is drawing the icon correctly, however, when I click on a row, the middle column, eg. column 1
is not being shown as selected. All other columns look selected whenever I click on a row.

Can somebody please help with having the selected row displayed correctly?

private void listView1_DrawColumnHeader(object sender, DrawListViewColumnHeaderEventArgs e)
{
e.DrawDefault = true;
}

private void listView1_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
{
if (e.ColumnIndex == 1)
{
e.DrawBackground();
e.Graphics.DrawImage(e.Item.ImageList.Images[e.Item.ImageIndex], e.SubItem.Bounds.Location);
e.Graphics.DrawString(e.SubItem.Text, e.SubItem.Font, new SolidBrush(e.SubItem.ForeColor), e.SubItem.Bounds.Location.X + this.imageListTask.Images[0].Width, e.SubItem.Bounds.Location.Y);
}
}

Many thanks,
Jr.
Oct 4 '08 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On Sat, 04 Oct 2008 12:28:10 -0700, James <sy********@yahoo.co.ukwrote:
[...]
I have overridden the DrawColumnHeader, DrawItem, DrawSubItem methods as
displayed below.
It is drawing the icon correctly, however, when I click on a row, the
middle column, eg. column 1
is not being shown as selected. All other columns look selected
whenever I click on a row.

Can somebody please help with having the selected row displayed
correctly?
I don't see anything in the code you posted that would render a selected
cell differently than an unselected one. What makes you think that the
selection should be represented while you are using the code that you
posted?

Pete

p.s. Please don't post HTML.
Oct 5 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.