473,387 Members | 1,529 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,387 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 5917
debasisdas
8,127 Expert 4TB
Question moved to Visual Basic Forum from VB Articles Section.
Feb 12 '08 #2
debasisdas
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.

Thanks,

Hiren
Feb 12 '08 #4
debasisdas
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

Hiren
Feb 12 '08 #6
debasisdas
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
Xrs.MoveFirst

While Xrs.EOF = False
Combo1.AddItem (Xrs("Name"))
Xrs.MoveNext
Wend
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.....

Hiren
Feb 12 '08 #8
debasisdas
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
  8.  
  9. End Sub
  10.  
  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
  19.  
  20.  
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,

Thanks,

Hiren
Feb 12 '08 #10
debasisdas
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.

Regards,

Hiren
Feb 12 '08 #12

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

Similar topics

5
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 and a dark blue text in a page's footnotes. And...
2
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 image behind each list item, the last list item will...
2
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 and content display should look like the image file...
5
by: Ike | last post by:
Does anyone know how to disable a list box element in VB 6 ? Thanks Ike
1
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 properties with regards to the listitems...
0
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 checkboxes. The problem is that the...
4
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 the contents of each list item, the element
2
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 want to disable the items of each of the page of...
0
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 can I make sure that query is executing properly,...
16
Frinavale
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 Item1, it has to be at the top): Item1 ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.