By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,154 Members | 1,050 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,154 IT Pros & Developers. It's quick & easy.

ListBox: Changing appearance of selection rectangle depending on focus?

P: n/a
Seems like I've been here before, but can't find anyting in Google.

I've got two list boxes on a form.

Seems to me like the inactive ListBox's selection rectangle should be something
like gray...otherwise, the user sees two ListBoxes, both with black selection
rectangles - and the user does not visually know which one he is "in". This
becomes relevant if we have a keyboard-type user - they want to hit "Enter" and
have something happen...but which list is it going to happen in?

Bottom line, is there some ListBox property that I can change in
GotFocus/LostFocus so that the rectangle is still there, but looks different?
--
PeteCresswell
Nov 13 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"(Pete Cresswell)" <x@y.z> wrote
I've got two list boxes on a form.

Seems to me like the inactive ListBox's selection rectangle should be something like gray...otherwise, the user sees two ListBoxes, both with black selection rectangles - and the user does not visually know which one he is "in". This becomes relevant if we have a keyboard-type user - they want to hit "Enter" and have something happen...but which list is it going to happen in?

Bottom line, is there some ListBox property that I can change in
GotFocus/LostFocus so that the rectangle is still there, but looks

different?

If you disable the unused listBox, not only will the listBox itself be
greyed out, but the selection bar will also be grey. Alternatively, you
could change the backcolor of the unused listBox. Finally, I'm guessing
that you could set the listBox.Value to Null, which would take the selection
off (guessing on last - didn't try it).
Darryl Kerkeslager
Nov 13 '05 #2

P: n/a
(Pete Cresswell) wrote:
Seems like I've been here before, but can't find anyting in Google.

I've got two list boxes on a form.

Seems to me like the inactive ListBox's selection rectangle should be something
like gray...otherwise, the user sees two ListBoxes, both with black selection
rectangles - and the user does not visually know which one he is "in". This
becomes relevant if we have a keyboard-type user - they want to hit "Enter" and
have something happen...but which list is it going to happen in?

Bottom line, is there some ListBox property that I can change in
GotFocus/LostFocus so that the rectangle is still there, but looks different?


I created a listbox; List0, and had the following events attached to it
Private Sub List0_GotFocus()
Me.List0.BackColor = 16777215
End Sub

Private Sub List0_LostFocus()
Me.List0.BackColor = 16711680
End Sub

It's up to you to be artistic with the colors.

You can even try this
Private Sub List0_GotFocus()
Me.List0.ForeColor = 0
End Sub

Private Sub List0_LostFocus()
Me.List0.ForeColor = 16711680
End Sub

And change the text color instead of the back color.

Nov 13 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.