472,353 Members | 1,573 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

Disable Some List Items from Combo Box !!!

Hiren Joshi
Hello All Experts,

I am a Moderate VB Programmer. I am developing one Application at the moment with VB 6.0 and MS Access. Operating System is Win XP. Its a Multi User application.

What I want to know is How do I Disable 2 or 3 Items from Combo Box?

I am using Combo Box with Style 2. and all Fields come from Access Table while loading the form. (e.g. If My List is A0, A1, A2, A3, A4...) and at run time if i want to Disable A1 and A3 from Selecting... Is it possible to do so?

Your quick response on this matter will be highly appreciated,

You can email me as well on mail id removed

Thanks & Regards,

Hiren (Nairobi - Kenya)
Feb 12 '08 #1
11 5778
8,127 Expert 4TB
Question moved to Visual Basic Forum from VB Articles Section.
Feb 12 '08 #2
8,127 Expert 4TB
You need to use ITEMDATA property of the control.
Feb 12 '08 #3
Hi Debasis,

Can you please tell me which ITEMDATA Propery I am supposed to use? Please if you can specify in details.


Feb 12 '08 #4
8,127 Expert 4TB
1.Set ItemDate property for desired items in the collection.
2.Check for the same in the click event and execute the further code.
Feb 12 '08 #5
Sorry but Still i dont have clear idea of it, if you can write for me a sample here.

Thanks in Advance

Feb 12 '08 #6
8,127 Expert 4TB
Kindly post the code that you have tried so far.
Feb 12 '08 #7
On Form Load Event My Code Follows:

If Xrs.State = adStateOpen Then Xrs.Close
Xrs.CursorLocation = adUseClient
Xrs.Open "select * from Table1 Order By SrNo", Con, adOpenKeyset, adLockOptimistic

If Xrs.RecordCount <> 0 Then

While Xrs.EOF = False
Combo1.AddItem (Xrs("Name"))
End If
and at run time it displays Value in Como1 like A0, A1, A2, A3, A4, A5, A6... Now I want A1 and A3 to be disabled... That means If I click on Combo1 I should be able to select all other values apart from A1 and A3.....

Feb 12 '08 #8
8,127 Expert 4TB
Try to follow the sample code

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command1_Click()
  2. i = List1.ListIndex
  3. If List1.ItemData(i) <> 10 Then
  4. List2.AddItem List1.List(List1.ListIndex)
  5. Else
  6. MsgBox "Can''t add This Item"
  7. End If
  9. End Sub
  11. Private Sub Form_Load()
  12. For i = 1 To 10
  13. List1.AddItem i
  14. Next i
  15. List1.ItemData(3) = 10
  16. List1.ItemData(5) = 10
  17. List1.ItemData(7) = 10
  18. End Sub
Feb 12 '08 #9
Yes Debasis,

This Works as well... But Can't it become Disable so that there is no chance of even selecting that Item even by Mistake?

But so far this code works,


Feb 12 '08 #10
8,127 Expert 4TB
It does not matter of the item is enabled or not . Our aim is to make that not selectable by the user.
Feb 12 '08 #11
Ok Sir,

That was a question just to know for my knowledge. Anyway Thank You once again for this help too.


Feb 12 '08 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

by: Peter Collinson | last post by:
Hi... Is there any way to style a List Item a different color and size than the <LI> in an Ordered List? I'd like a red super-script number...
by: Unknown User | last post by:
How can I separate list items displayed inline by vertical bars | ? If I use a background image that simulate a vertical bar, and I put this bg...
by: deepakp | last post by:
Hi, I'm trying to create a site index page. The page layout will consist of a header, left navigation and content display. The left navigation...
by: Ike | last post by:
Does anyone know how to disable a list box element in VB 6 ? Thanks Ike
by: RSH | last post by:
Hi, I have a situation where I need to add several "Hidden" properties to list items in a dropdownlist. By default the DropDownList item has two...
by: John Dalberg | last post by:
using VS 2005. I have an unordered list with list items which are displayed horizontally. Some of the list items have hyper links and some have...
by: Keith Hughitt | last post by:
For example, If you have a list: <ul> <li>item 1 is short.</li> <li>item 2 is a little bit longer</li> </ul> regardless of the size of...
by: Claudia Fong | last post by:
Hi, I added a tabcontrol in a panel in my form. My tabcontrol have more than 3 pages.. each page contains textboxes, combobox, checkbox. I...
by: c0mrade | last post by:
I have a problem with getting the list items, below is my hibernate code, after that code there is my method ..and below that is my junit test. How...
by: Frinavale | last post by:
What I'd like to do is take a list and display it's items in a circle. For example (the order of the in the circle doesn't matter..except for...
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand....

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.