473,396 Members | 2,113 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

ListBox: Changing appearance of selection rectangle depending on focus?

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
2 6785
"(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
(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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Philippe Meunier | last post by:
Hi, I would like to know How I could draw a Dashed rectangle over everything in a container. I will use this to draw a selection rectangle (like in VB.NET Form Designer UI). And even it draws in...
5
by: (Pete Cresswell) | last post by:
I've got a TreeView on the left of my screen. As the user navigates the tree, I load corresonding detail info into the rest of the screen. Works ok, but when the user clicks on a detail field,...
10
by: Tyrant Mikey | last post by:
I don't know if this can even be done, but I'd REALLY like to eliminate the selection rectangle that appears around my ImageButton controls when the user clicks on them. The buttons are on a black...
10
by: Steven Smith | last post by:
I'm trying to display the contents of the me.NamesListBox.SelectedItems property to a label on the form. This works fine in single selection mode but there's obviously something wrong with my...
11
by: thom | last post by:
Hello everybody, Here is a little javascript that gives me the mouse's x and y coordinates. Now, i'd like to be able to make selection(s) rectangle(s) on a given image with it. And then,...
0
by: (PeteCresswell) | last post by:
Got a TreeView control on the screen. User clicks a node, screen loads details for that node. Screen has two modes: Browse and Edit. If the user clicks "Edit", I set Tree.Enabled=False and...
3
by: Doc John | last post by:
We have a rather big Windows application which includes an MDI and children Forms. We would like to change its appearance dramatically (nicer controls: buttons, tab controls, textboxes, grids)...
0
by: Gunnar Hurtig | last post by:
Hi All I am relatively new to Tkinter and am putting a wraparound to the ATNF ASAP program. In one part I present several long lists in list boxes for selection. My code will remember the multiple...
1
by: manivelk | last post by:
Hi there, I try to create a ListBox with multiple selection. The ListBox is filled with Data from a database once on Page_Load. When I click the button to submit the form all selections will...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.