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

Disable mouse click. 1

Status
Not open for further replies.

abcd12344445555

Programmer
May 10, 2009
24
0
0
BR
Is there a way to disable mouse clicks on a listBox? I dont want users changing lisbox's ItemIndex by clicking on it.


Regards
Paul.
 
I'm not certain why you do not want to allow the user to change the ItemIndex. The ItemIndex returns the index number of the item in the list box that the user has selected. Without the ItemIndex, you won't know what the user has selected.

Nevertheless, if you really want to disable it, you have to disable the item. To do this you have to create an owner drawn list. Look at these articles for more info:

Disabling a Combo Box or List Box Item

Owner-Drawn List Boxes

More on Owner-Drawn List Boxes

BCB Commonly Asked Questions on List Boxes


James P. Cottingham
[sup]I'm number 1,229!
I'm number 1,229![/sup]
 
The main idea is to lock the listbox, I don't want users changing the selected item by clicking on the listbox. They will navigate through the list by other means.
 
Can't you add a WndProc() function to the Form to catch windows messages to it and to filter out those which are mouse clicks to the box ?
 
Or you can: ListBox1->Enabled=false
And by code you can set ListBox1->ItemIndex =x
 
Yes. That was the solution I used to this problem. Should have posted here...
Very straight-forward, but you need to do some tricks to get rid of the "grayed text". A good solution though.
 
A better option is to put the listbox in a parent control such as a panel and disable that control while leaving the listbox as Enabled==true. The listbox will not be gray-texted in this way.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top