-
May 24th, 2017, 03:11 AM
#1
Thread Starter
Enjoy the moment
[RESOLVED] how do i color each listsubitems?
hey
is there a way to color each listsubitem row?
e.x
first row name is salsa and the color is red
second row is mambo the color is green
this is the code i am using to load from the database
Code:
Dim Rs As New ADODB.Recordset
Rs.Open "Select * From PriceList Order By PriceName", CN
LsVw.ListItems.clear
Do While Not Rs.EOF
Set itm = LsVw.ListItems.Add(, , Rs!PriceName, 1)
itm.SubItems(1) = Rs!PriceColor ' Here i want the color
Rs.MoveNext
Loop
Rs.Close
of course i need to loop to get for each name its color
appreciate any help
salsa
Last edited by salsa31; May 24th, 2017 at 03:14 AM.
-
May 24th, 2017, 03:39 AM
#2
Re: how do i color each listsubitems?
-
May 24th, 2017, 04:09 AM
#3
Thread Starter
Enjoy the moment
Re: how do i color each listsubitems?
Originally Posted by Arnoutdv
hey
i saw this but its not helping me that much
because i have individuales colors that i save
-
May 24th, 2017, 04:12 AM
#4
Re: how do i color each listsubitems?
I don't understand what you mean.
It's a routine so set the backcolor of a single listview row.
What doesn't work for you?
-
May 24th, 2017, 05:21 AM
#5
Thread Starter
Enjoy the moment
Re: how do i color each listsubitems?
Originally Posted by Arnoutdv
I don't understand what you mean.
It's a routine so set the backcolor of a single listview row.
What doesn't work for you?
too complicated for me
-
May 24th, 2017, 06:15 AM
#6
Thread Starter
Enjoy the moment
Re: how do i color each listsubitems?
well i played a little with the code and this is the result i got
Code:
Private HairColor(35) As Long
HairColor(1) = RGB(255, 148, 132)
HairColor(2) = RGB(132, 156, 231)
HairColor(3) = RGB(165, 222, 99)
HairColor(4) = RGB(231, 231, 214)
HairColor(5) = RGB(255, 181, 115)
HairColor(6) = RGB(132, 239, 247)
HairColor(7) = RGB(214, 206, 132)
HairColor(8) = RGB(198, 165, 247)
HairColor(9) = RGB(165, 206, 198)
HairColor(10) = RGB(255, 231, 115)
HairColor(11) = vbRed
HairColor(12) = RGB(75, 0, 130)
HairColor(13) = RGB(0, 255, 255)
HairColor(14) = RGB(113, 198, 113)
HairColor(15) = RGB(139, 35, 35)
HairColor(16) = RGB(227, 207, 87)
HairColor(17) = RGB(255, 255, 0)
HairColor(18) = RGB(99, 184, 255)
HairColor(19) = RGB(165, 42, 42)
HairColor(20) = RGB(65, 105, 225)
HairColor(21) = RGB(255, 239, 213)
HairColor(22) = vbBlack
HairColor(23) = RGB(255, 182, 193)
HairColor(24) = RGB(205, 92, 92)
HairColor(25) = RGB(240, 128, 128)
HairColor(26) = RGB(255, 127, 80)
HairColor(27) = RGB(128, 128, 0)
HairColor(28) = RGB(72, 61, 139)
HairColor(29) = RGB(0, 128, 128)
HairColor(30) = RGB(216, 191, 216)
HairColor(31) = RGB(219, 112, 147)
HairColor(32) = RGB(25, 25, 112)
HairColor(33) = RGB(70, 130, 180)
HairColor(34) = RGB(255, 0, 255)
HairColor(35) = vbBlue
Code:
Dim RsH As New ADODB.Recordset
RsH.Open "SELECT * from ColorDiary ORDER BY TreatName", CN
LsVw.ListItems.clear
Do While Not RsH.EOF
Set itm = LsVw.ListItems.Add(, , RsH!UserName)
itm.SubItems(1) = HairColor(RsH!UserColorNumber)
itm.ListSubItems(1).ForeColor = HairColor(RsH!UserColorNumber)
RsH.MoveNext
Loop
RsH.Close
-
May 24th, 2017, 06:23 AM
#7
Re: how do i color each listsubitems?
-
May 24th, 2017, 06:53 AM
#8
Re: how do i color each listsubitems?
Purple, green and blue hair? Guess Spain has some weirdos also!
Is that the result you wanted...like A says, looks fine, except --
What happens if the backcolor of your control (looks like white) and one or more of your customers has/have white hair (kinda like mine is getting)...the forecolor would be white and you would not be able to see the number. And variants of grey might also not be very visible.
-
May 24th, 2017, 07:24 AM
#9
Thread Starter
Enjoy the moment
Re: how do i color each listsubitems?
Originally Posted by Arnoutdv
Looks fine, doesn't it?
instead of the number i want it to be colored
-
May 24th, 2017, 09:16 AM
#10
Re: how do i color each listsubitems?
Don't assign a text and set the .BackColor
Code:
Set itm = LsVw.ListItems.Add(, , RsH!UserName)
itm.SubItems(1) = ""
itm.ListSubItems(1).BackColor = HairColor(RsH!UserColorNumber)
RsH.MoveNext
Loop
Or if you need to retrieve the actual UserColorNumber later from the ListView then you can do this:
Code:
Set itm = LsVw.ListItems.Add(, , RsH!UserName)
itm.SubItems(1) = RsH!UserColorNumber
itm.ListSubItems(1).ForeColor = HairColor(RsH!UserColorNumber)
itm.ListSubItems(1).BackColor = HairColor(RsH!UserColorNumber)
RsH.MoveNext
Loop
-
May 24th, 2017, 12:34 PM
#11
Thread Starter
Enjoy the moment
Re: how do i color each listsubitems?
Originally Posted by Arnoutdv
Don't assign a text and set the .BackColor
Code:
Set itm = LsVw.ListItems.Add(, , RsH!UserName)
itm.SubItems(1) = ""
itm.ListSubItems(1).BackColor = HairColor(RsH!UserColorNumber)
RsH.MoveNext
Loop
Or if you need to retrieve the actual UserColorNumber later from the ListView then you can do this:
Code:
Set itm = LsVw.ListItems.Add(, , RsH!UserName)
itm.SubItems(1) = RsH!UserColorNumber
itm.ListSubItems(1).ForeColor = HairColor(RsH!UserColorNumber)
itm.ListSubItems(1).BackColor = HairColor(RsH!UserColorNumber)
RsH.MoveNext
Loop
tnx it gave me a start
-
May 24th, 2017, 12:51 PM
#12
Re: [RESOLVED] how do i color each listsubitems?
Arno
I don't think this will work .. BackColor does not seem to be a valid property
Code:
Do While Not RsH.EOF
Set itm = LsVw.ListItems.Add(, , RsH!UserName)
itm.SubItems(1) = ""
itm.ListSubItems(1).BackColor = HairColor(RsH!UserColorNumber)
RsH.MoveNext
Loop
I think this is the best that can be done .. ForeColor
Code:
Do While Not RsH.EOF
Set itm = LsVw.ListItems.Add(, , RsH!UserName)
itm.SubItems(1) = ""
itm.ListSubItems(1).ForeColor = HairColor(RsH!UserColorNumber)
RsH.MoveNext
Loop
EDIT
I'm assuming that LsVw.View = lvwReport.
FWIW, .Bold is also a usable property
Spoo
Last edited by Spooman; May 24th, 2017 at 01:02 PM.
-
May 24th, 2017, 01:00 PM
#13
Re: [RESOLVED] how do i color each listsubitems?
This is easy using a flexgrid. I steer from the listview (personal choice).
Sam
-
May 24th, 2017, 04:09 PM
#14
Re: [RESOLVED] how do i color each listsubitems?
Sam
I'll second that. FlexGrid is very (ahem) flexible.
Salsa
Despite this thread being marked Resolved, any reason not to use a FlexGrid?
Spoo
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|