Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm Controls / October 2008

Tip: Looking for answers? Try searching our database.

OwnerDraw ListView subitem problems

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
James - 05 Oct 2008 00:38 GMT
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.
Jeff Gaines - 05 Oct 2008 12:33 GMT
On 05/10/2008 in message <eecpQpnJJHA.1556@TK2MSFTNGP03.phx.gbl> James
wrote:

>private void listView1_DrawSubItem(object sender,
>DrawListViewSubItemEventArgs e)
[quoted text clipped - 9 lines]
>}
>}

I'm pretty sure I have sen this in another group.
Anyway, you always draw the sub-item in the same style from your code. If
you want it to look different for different states you need to check its
state and draw it accordingly.

Signature

Jeff Gaines Damerham Hampshire UK
It may be that your sole purpose in life is to serve as a warning to others.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.