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

Disabling an item in a listbox

Status
Not open for further replies.

Mike Lewis

Programmer
Jan 10, 2003
17,516
Scotland
I feel sure I know the answer to this one, but I can't seem to grasp it.

I want to disable certain items in a listbox. I know I can do that by placing a backslash in front of the item. That has always worked in the past, when I used AddItem to populate the listbox.

But now I want to disable items in a listbox populated directly from a table (RowsSourceType = 6). I thought I could just put the backslash at the front of the field within the table, but it doesn't work.

Is it possible to disable items in a listbox when the RowSourceType is 6? If so, how?

Thanks in advance.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Mike,

According to KiloFox, the backslash technique of disabling an item only works for rowsource types of 0, 1, and 5.

Regards,
Jim
 
Jim,

That's what I was afraid of.

I guess I'll just have to re-design my listbox class. My aim is to show certain items in a different colour so that they can serve as headings. I thought disabling them would be an easy way to do that, but apparently not.

Thanks for your reply.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Mike,

That's an interesting idea. Could you do a SELECT ... INTO ARRAY and use that as your rowsource?

Just a thought,
Jim
 
Jim,

In fact, I've now changed the class so that it uses AddItem to populate the listbox (it only took five minutes to do that).

The relevant items are now correctly disabled, in that the highlight skips over them. But I can't get them to show up in the disabled colours. I have set DisabledItemBackColor and DisabledItemForecolor to two distinct values, but the disabled items still show the same colours as all the others.

Anybody got any ideas as to what I might be doing wrong?

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Mike,

I just tried and it worked fine. But, is it possible you used DisabledForeColor and BackColor instead of DisabledItemForeColor and BackColor (as I did the first time I tried it)?

Regards,
Jim
 
Jim,

I'm definitely using DisabledItemForeColor and DisabledItemBackColor.

There must be something else in the class that's intefering with this. I guess I'll have to rebuild it from scratch to find the answer.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 

OK, I've got it sussed now.

To disable an item in a listbox, you need to add the backslash to the value in every column. I didn't realise that.

I had added a second (invisible) column to hold the record number (so that I could navigate to the correct record as the user moves the highlight). I just needed to add the backslash to the record number as well as to the text in the visible column.

It's all working perfectly now.

Jim, thanks for your help.

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Mike,

Glad you got it sorted! And that's a new one to me also.

Jim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top