473,464 Members | 1,510 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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.
Oct 4 '08 #1
1 6392
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: John Lauwers | last post by:
I know you can edit the first column of the listview control, is there a way to edit the second and/or the other columns? greets John
6
by: Richard | last post by:
Hi. I use a ListView to display data in tabular form. Each ListView row corresponds to a data record. The ListView Item of the record is the record key or code. Each SubItem in that row...
1
by: andrewcw | last post by:
The clcik event on the ListView control seems to trigger off the item level ( the first column ). I would like to be able to trap the click event on a particular subitem ( a specific column's row...
6
by: Jack | last post by:
Hello, I've noticed through searching this group's previous posts that one can get the item the mouse is over in a listview control but I did not see how to get the subitem the mouse is over. Is...
1
by: Lars Netzel | last post by:
Is it possible to have 5 Subitems in a listview and only take over the draw item for the last of them or do I have to draw the whole item? I just realized I need a little image before the text in...
10
by: Adam Honek | last post by:
This is probably a silly question but oh well, I can't find the answer looking via code. Having an imagelist already, how does one set an icon for a list view's sub items? I'm using the code...
1
by: tmda | last post by:
I'm using OwnerDraw for some customization in my ListView - adding color to item backgrounds. I'm using the ListView specifically for it's OwnerDraw capability. I originally was using the...
1
by: FireFlux | last post by:
Inherit the Listview Control with Visual Basic ? I have decided do inherit the Listview control some days ago to change some painting things to make the .net Listview look like the explorer's...
2
by: =?iso-8859-1?B?S2VyZW0gR/xtcvxrY/w=?= | last post by:
Hi, i know how to work with the owner draw mode in the ListView-Class, but how do i draw the last three dots in a column if the text exceeds the columns width? To make it clear, i am talking...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.