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

How to verify if selected combobox item is disabled?

Status
Not open for further replies.

Paco75

Programmer
Oct 11, 2001
239
US
Hi,

Let say i got a combobox initialised like this

Code:
this.RowSourceType = 1
this.RowSource = "item1,/item2"

how can i validate if selected item is disabled or not?
 
selected item is disabled or not

What do you mean "disabled or not" ?

Disabled where?

If it is Disabled in your Combobox, then it should not be an available option to select.

If it is Disabled somewhere else, your own code will need to check it and do whatever is necessary.

Good Luck,
JRB-Bldr
 
The combo box i loaded with a list of items that some items will have a "/" before to disable them. Depending on many things the same combo box will have the same items but some will be disabled inside.

example the same combo box can have these list:

combobox:
- "item1"
- "item2"
- "/item3" && Disabled in combobox
- "item4"

combobox:
- "/item1" && Disabled in combobox
- "item2"
- "item3"
- "/item4" && Disabled in combobox

i need to verify if the first combobox item is enabled because sometime the form is loaded and the combobox is placed on the first item even if it is disabled.
 
My first thought is that none of your items will be disabled.

The escape character is a backslash, not a forward slash

\Item1 && disabled

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.
 
My second thought is that this may not be natively possible.

You probably need to populate the list from a two dimensional array (value, endabled) and then test your value against that list.



Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.
 
There is no way to access an item from a combo box and read it's properties?

PS: Yeah you are right i put slashes in my post but in my code it was back slashes... mistyped! :p
 
Just check the item itself. If you're in code in the combo, use:

This.List[1]

for example, to look at the content of the first item. You can then check for the "\"

Tamar
 
That doesn't work in VFP9 Tamar, the \ escape character is NOT passed back.



Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.
 
Hi,
To varify check only for (citem,1)="\" will only work if you never have to add an item which begins with a \. You should also check for left(cItem,2)="\]".
Since you most probably populate your combo with an array, you could also consider to add an extra dimension to your array "disabled" and populate that column with .T. if condition is true and check your array column on disabled=.f.

Jockey(2)

 
The combo box i loaded with a list of items that some items will have a "/" before to disable them. Depending on many things the same combo box will have the same items but some will be disabled inside.

If that is what you want, then why are you 'populating' your ComboBox with Values?

Why not set the ComboBox up with its RowSourceType = ALIAS and then just manipulate the Records (DELETE/RECALL) in the associated Cursor/Table as needed (example: SET FILTER TO !DELETED()) to Enable/Disable the 'rows' shown in the ComboBox?

It would be much easier than depending on an ESC character in the Values data itself.

Good Luck,
JRB-Bldr
 
Sorry. I wrote off the top of my head without testing. I was mistaken.

Tamar
 
FWIW
see thread184-1659274
There's a bug which allows you to select a disabled item using keyboard.
-Bart
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top