Ok. I haven't been around for a while, so I hope someone will come to my
rescue. I thought I had done this years ago, but I have scoured my code
snippets and can't find it.
I want my ListView control to have a different background colour on
alternate rows. I'm using VS2005.
Firstly, I'm surprised that I can't do it out of the box. But secondly, I
can't find a really simple one-liner that let's me do it by overriding
something.
I could owner draw, or custom draw, but these seem to be the hammer to crack
the nut. Is there a way to do this easily?
Failing that, what is the preferred way?
TIA
Charles 3 2179
On Oct 14, 11:59 pm, "Charles Law" <bl...@nowhere.comwrote:
Ok. I haven't been around for a while, so I hope someone will come to my
rescue. I thought I had done this years ago, but I have scoured my code
snippets and can't find it.
I want my ListView control to have a different background colour on
alternate rows. I'm using VS2005.
Firstly, I'm surprised that I can't do it out of the box. But secondly, I
can't find a really simple one-liner that let's me do it by overriding
something.
I could owner draw, or custom draw, but these seem to be the hammer to crack
the nut. Is there a way to do this easily?
Failing that, what is the preferred way?
TIA
Charles
You can do it out of the box.
dim yellow as boolean = true
For each lvi as ListViewItem in lvItems
if (yellow) then
lvi.backcolor = color.yellow
else
lvi.backcolor = color.white
end if
yellow = not yellow
Next
Hi Phillip
Thanks for the response.
What happens when I add an item? Does it get the correct background
according to whether the new row is odd or even?
In addition, I would like the grid to have alternate colours for the rows,
irrespective of whether there are any items in the list.
Charles
"Phillip Taylor" <Ph*****************@gmail.comwrote in message
news:11**********************@i13g2000prf.googlegr oups.com...
On Oct 14, 11:59 pm, "Charles Law" <bl...@nowhere.comwrote:
>Ok. I haven't been around for a while, so I hope someone will come to my rescue. I thought I had done this years ago, but I have scoured my code snippets and can't find it.
I want my ListView control to have a different background colour on alternate rows. I'm using VS2005.
Firstly, I'm surprised that I can't do it out of the box. But secondly, I can't find a really simple one-liner that let's me do it by overriding something.
I could owner draw, or custom draw, but these seem to be the hammer to crack the nut. Is there a way to do this easily?
Failing that, what is the preferred way?
TIA
Charles
You can do it out of the box.
dim yellow as boolean = true
For each lvi as ListViewItem in lvItems
if (yellow) then
lvi.backcolor = color.yellow
else
lvi.backcolor = color.white
end if
yellow = not yellow
Next
I should add that I want the background of alternate rows coloured
differently, even when there are no items in the list view. So, setting the
background colour of each item doesn't work.
Does anyone have an idea?
Charles
"Charles Law" <bl***@nowhere.comwrote in message
news:uQ**************@TK2MSFTNGP05.phx.gbl...
Ok. I haven't been around for a while, so I hope someone will come to my
rescue. I thought I had done this years ago, but I have scoured my code
snippets and can't find it.
I want my ListView control to have a different background colour on
alternate rows. I'm using VS2005.
Firstly, I'm surprised that I can't do it out of the box. But secondly, I
can't find a really simple one-liner that let's me do it by overriding
something.
I could owner draw, or custom draw, but these seem to be the hammer to
crack the nut. Is there a way to do this easily?
Failing that, what is the preferred way?
TIA
Charles
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: aznFETISH |
last post by:
I have a list of links that I ue on my page, I alternate background colors
for these links in a table, I usually do it using a DB but this list of link
is manually added into the page so my...
|
by: Els |
last post by:
Hi,
I would like an opinion on the following:
I have a page which is made up of background-images with transparent
linked images in front of it, which on hover show text in CSS popups.
Due to...
|
by: Peter Williams |
last post by:
Hi All,
I want to write some javascript for a html page which does the
following.
Imagine that the page contains a table with 2 columns and 3 rows, e.g.:
+---+---+
| A | B |
+---+---+
|
by: Doug Laidlaw |
last post by:
I tried to grab an image from a Web page the other day. It turned out that
the page was made up of three horizontal bands, and part of the image was
in each. One band was a JPEG, another was a...
|
by: Matt B |
last post by:
I have a need to alternate output row colour where not every row in the
sequence is output, so I cannot base the colour on whether position() is odd
or even.
e.g.
....
<xsl:for-each...
|
by: sconeek |
last post by:
Hi all,
I am generating a html based table with multiple rows of data coming
in real time from a postgres DB. The underlying technology is java
based however the front end is html.
now i am...
|
by: Eric Lindsay |
last post by:
I am trying to understand the differences between and uses of
persistent, default and alternate styles. I have read
http://www.w3.org/TR/REC-html40/present/styles.html section 14.3.2 on...
|
by: sconeek |
last post by:
hi all,
my java servlet code has a foreach loop which automatically generates a
HTML table with x number of rows.
now my problem is that I would like the rows to be alternating in
colour so that...
|
by: Mr. B |
last post by:
I've not programmed for a while in VB 2003... but I've decided to modlfiy a
Project I have.
Seems simple enough... I've a List Box... I fill it with about 30 lines of
data (3-4 columns).
What...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |