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)
11 5917
Question moved to Visual Basic Forum from VB Articles Section.
You need to use ITEMDATA property of the control.
Hi Debasis,
Can you please tell me which ITEMDATA Propery I am supposed to use? Please if you can specify in details.
Thanks, Hiren
1.Set ItemDate property for desired items in the collection.
2.Check for the same in the click event and execute the further code.
Sorry but Still i dont have clear idea of it, if you can write for me a sample here.
Thanks in Advance
Hiren
Kindly post the code that you have tried so far.
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
Try to follow the sample code -
Private Sub Command1_Click()
-
i = List1.ListIndex
-
If List1.ItemData(i) <> 10 Then
-
List2.AddItem List1.List(List1.ListIndex)
-
Else
-
MsgBox "Can''t add This Item"
-
End If
-
-
End Sub
-
-
Private Sub Form_Load()
-
For i = 1 To 10
-
List1.AddItem i
-
Next i
-
List1.ItemData(3) = 10
-
List1.ItemData(5) = 10
-
List1.ItemData(7) = 10
-
End Sub
-
-
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
It does not matter of the item is enabled or not . Our aim is to make that not selectable by the user.
Ok Sir,
That was a question just to know for my knowledge. Anyway Thank You once again for this help too.
Regards,
Hiren
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 and a dark blue text in a page's
footnotes. And...
|
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...
|
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...
|
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
properties with regards to the listitems...
|
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...
|
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
|
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...
|
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,...
|
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
...
|
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,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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,...
|
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...
| |