Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Format background text color in a ListView box

Status
Not open for further replies.

vamoose

Programmer
Oct 16, 2005
320
MX
I am using Access 2000 which has a form containing 1 ListView box. I am using the following code to color the text within the ListView:

Function FormatColors()

Dim Item As ListItem: Dim Counter As Long: Dim Color As String

For Counter = 1 To [Forms]![frm_Schedule_list].ListView1.ListItems.Count
Set Item = [Forms]![frm_Schedule_list].ListView1.ListItems.Item(Counter)
Priority = Item.SubItems(10): With [Forms]![frm_Schedule_list].ListView1
If Priority = 0 Then 'Red
.ListItems.Item(Counter).ForeColor = 255
.ListItems.Item(Counter).ListSubItems(1).ForeColor = 255
.ListItems.Item(Counter).ListSubItems(2).ForeColor = 255
.ListItems.Item(Counter).ListSubItems(3).ForeColor = 255
.ListItems.Item(Counter).ListSubItems(4).ForeColor = 255
.ListItems.Item(Counter).ListSubItems(5).ForeColor = 255
.ListItems.Item(Counter).ListSubItems(6).ForeColor = 255
.ListItems.Item(Counter).ListSubItems(7).ForeColor = 255
.ListItems.Item(Counter).ListSubItems(8).ForeColor = 255
.ListItems.Item(Counter).ListSubItems(9).ForeColor = 255
End If

Next Counter

Exit Function

I would like to know if it is possible to format the background color of the text also maybe something like this

Function FormatColors()

Dim Item As ListItem: Dim Counter As Long: Dim Color As String

For Counter = 1 To [Forms]![frm_Schedule_list].ListView1.ListItems.Count
Set Item = [Forms]![frm_Schedule_list].ListView1.ListItems.Item(Counter)
Priority = Item.SubItems(10): With [Forms]![frm_Schedule_list].ListView1
If Priority = 1 Then 'Yellow
.ListItems.Item(Counter).BackColor = 65535
.ListItems.Item(Counter).ListSubItems(1).BackColor = 65535
.ListItems.Item(Counter).ListSubItems(2).BackColor = 65535
.ListItems.Item(Counter).ListSubItems(3).BackColor = 65535
.ListItems.Item(Counter).ListSubItems(4).BackColor = 65535
.ListItems.Item(Counter).ListSubItems(5).BackColor = 65535
.ListItems.Item(Counter).ListSubItems(6).BackColor = 65535
.ListItems.Item(Counter).ListSubItems(7).BackColor = 65535
.ListItems.Item(Counter).ListSubItems(8).BackColor = 65535
.ListItems.Item(Counter).ListSubItems(9).BackColor = 65535
End If

Next Counter

Exit Function

I have tried this with no success. Thank you all for the help.
 
The quick answer is no, you can't do what you are asking.
The slightly longer answer is still no, you can't do what you want, but you may have some luck with this.
It's written for A97 & I have used it with A97, but it's not very stable and a little slow. I've not been able to get it working with A2k3 (the only version I have now), but YMMV.

hth

Ben

----------------------------------------------
Ben O'Hara
David W. Fenton said:
We could be confused in exactly the same way, but confusion might be like Nulls, and not comparable.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top