Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 108
Default multiselect listbox backcolor

Thanks Dave - and not too much code. Works like a charm.
--
russ


"Dave Peterson" wrote:

Not too much code:

Option Explicit
Private Sub CommandButton1_Click()
Dim myArr() As Boolean
Dim iCtr As Long
ReDim myArr(0 To Me.ListBox1.ListCount - 1)

For iCtr = 0 To Me.ListBox1.ListCount - 1
myArr(iCtr) = Me.ListBox1.Selected(iCtr)
Next iCtr
Me.ListBox1.BackColor = vbRed

For iCtr = 0 To Me.ListBox1.ListCount - 1
Me.ListBox1.Selected(iCtr) = myArr(iCtr)
Next iCtr

End Sub
'for testing
Private Sub UserForm_Initialize()
Dim iCtr As Long
With Me.ListBox1
.MultiSelect = fmMultiSelectMulti
For iCtr = 1 To 10
.AddItem iCtr
Next iCtr
End With
End Sub



Russ wrote:

I have a form with several textboxes, comboboxes and multiselect listboxes.
I would like to change the backcolor of each without changing the value in
each. A simple statement like:
Me.textbox1.backcolor = VbRed changes the backcolor of textboxes without
changing the textbox.value
Me.combobox1.backcolor = VbRed changes the backcolor of comboxes without
changing the combobox.value
However, Me.listbox1.backcolor = VbRed changes the backcolor of multiselect
listboxes but also resets the listbox1 to no selections.

Does anyone know a way to change the color of a multiselect listbox and keep
its selections without a lot of code to remember the array settings?

--
russ


--

Dave Peterson

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiselect Listbox use RKS Excel Discussion (Misc queries) 1 May 12th 06 03:04 PM
MultiSelect ListBox StephanieH Excel Programming 5 November 20th 04 12:29 AM
problems resetting backcolor in listbox Kelley[_3_] Excel Programming 0 November 1st 04 10:23 PM
Multiselect Listbox Francis Ang[_3_] Excel Programming 2 October 25th 04 01:57 AM
multiselect listbox CG Rosén Excel Programming 2 December 28th 03 05:17 PM


All times are GMT +1. The time now is 12:45 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"