OwnerDraw ListView subitem problems



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.

Relevant Pages

  • OwnerDraw ListView subitem problems
    ... I have an ownerdraw ListView control. ... I'm trying to use an ownerdrawn ListView control to draw and display images ... private void listView1_DrawColumnHeader(object sender, ... DrawListViewColumnHeaderEventArgs e) ...
    (microsoft.public.dotnet.framework.windowsforms.controls)
  • Re: Can I force display of full email address?
    ... Double click the message in the list so it opens its own window, ... >I just set the display name in the address book to the ... That is up to the sender. ... MSOE is "either, or"; if there is ...
    (microsoft.public.windows.inetexplorer.ie6_outlookexpress)
  • dsolefile issues when file is open through share
    ... I use the dsolefile to read the ... Object reference not set to an instance of an ... Private Sub Page_Load(ByVal sender As System.Object, ... Display use Fill Full Name If OLE not Available ...
    (microsoft.public.dotnet.languages.vb)
  • Re: I received a file aImage.mdi in my e-mail. How do I open it???
    ... ..MDI files, unfortunately it's also the only one that can ... display them for viewing. ... Ask the sender to save the ...
    (microsoft.public.office.misc)
  • Re: Viewing attachments in hotmail
    ... That could be the fault of the sender. ... Image May Not Appear in Message Sent with Outlook Express ... browser can display directly. ...
    (microsoft.public.internet.mail)