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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing Forecolor in listview control 1

Status
Not open for further replies.

compucop

Technical User
Sep 24, 2002
107
US
Anybody know how to change forecolor in listview control and also to enable full select. I found article on web about changing full select but could not get it to work. any help is greatly appreciated.
 
OK, This is how to change the forecolor.
*** listview6.listsubitems(1).forecolor = vbred
that will change the color in listview column.
 
Solved my own problem. FYI. You can conditionally format a listbox. Use the microsoft listview 6.0 activeX control. Do the following.

' place in onload event of form with listview 6.0 control

dim LV as object
dim itm as MSComctlLib.listitem

' Use this for all column headers, control must have headers before field can be populated.

dim col as MsComctllib.Columnheader

' set the listview control to full select, which will make it act like a listbox.

me.listview0.fullrowselect = true

set LV = Me.listview0

lvl.view = 3 ' report view for listview

' clear listbox
Lv.listitems.clear
lv.columnheaders.clear

set col = Lv.columnheaders.add _(,,"ColumnName",Listview0.width / 5)
' "ColumnName is name of your column. Width is placed 'behind column. If you don't display the columns the user won't be able to move the lists. Use same statement for each additional column, changing your column name each time.



' loop your recordset

dim rs as adodb.recordset
dim cn as adodb.connection
set rs = new adodb.recordset
set cn = currentproject.connection
rs.open "SELECT * FROM TABLE",cn,adopenstatic

do until rs.eof
set itm = Lv.listitems.add(,,rs!Field)
' rs!field / name of field you want to put in column.
' for each additional column use this statement.
set itm = lv.subitems(1) = rs!field1
' change subitems(1) to subitems(2) and so on for each additional field.
' conditionally formatting listview.
itm.forecolor = vbred
' changes first column. Utilize If statement to conditionally format.
itm.listsubitems(1).forecolor = vbred
' change listsubitems(number) to reflect column you want to have the forecolor changed. Incorporate if statements with the following statements and you can change the color of the listbox.
' to get a value from the listview use this command on a click event,

me.listview0.selecteditem.text

' this will give you the value of the first column of your listview (listbox)

Hope this information helps somebody!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top