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

Combobox little problem

Status
Not open for further replies.

TheBlainer

Programmer
Aug 31, 2011
37
CA
Hi
I have a form with a combobox with 8 elements in it.

Now, in the interactivechange of this combobox, it calls a form(named frmMoreInfo) for more information on the choice.
I want frmMoreInfo to be called anytime I click on one of the choice in the combobox EVEN if it's the same item that is already selected.

The problem is that with interactivechange, it doesn't apply on selecting the same item.

I tried with valid and it was doing what I want. But it's when it lost focus and when I click on a button or something else, valid is called again and I see another time my frmMoreInfo.

I tried click, but it wasn't great, because frmMoreInfo was called too easily and too much time.

So I was wondering if there was a way or trick to make it work correctly with interactivechange, valid or click to make what I want to do working

Thanks

TheBlainer
 
Looks like valid is your best candidate. SET EVENTTRACKING ON and see what events occur in what order. You might set a flag in an event occuring before you change the selection, not occurring if you simply move focus somewhere else. Then reset that flag in valid. If valid occurs and the falg is not set you have a case of simply moving on to another control without display of more info.

Bye, Olaf.
 
You say you want to fire the event even if the item in question is the one that's already selected. But if it's already selected, won't the MoreInfo form also be already open? In which case, it will simply stay open when you click the same item, which is what you want?

Perhaps the problem is that the MoreInfo form isn't open initially, when you instantiate the combo and first set its value. Maybe you should consider doing that - in other words, arranging it so that the form is always open whenever the combo box is visible.

It could be I've misunderstood the issue, in which case my apologies.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Thanks for your help you all
But only Olaf gave me an idea, because all your answers didn't really help me. So i used the debugger and after some tests. It gave me this.

To reolve my problem, I did :
- In the beginning of the init of the form, I create a variable
Code:
PUBLIC DONTDOIT
DONTDOIT = .F.
- I use this variable in 3 method of my combobox
First, valid
Code:
IF !DONTDOIT THEN
    DO FORM frmMoreInfo
ENDIF
Second, lostfocus
Code:
DONTDOIT = .T.
Third, dropdown
Code:
DONTDOIT = .F.
With that it's working like a charm ^^
I'm pretty sure that you can understand what I did if you try, well I hope... '^^
Thanks all

TheBlainer
 
I urge you to find a better approach. Public variables are accidents waiting to happen.

Why not make that variable into a form property?

Tamar
 
Listen to Tamar.

The flag you need could also be put into a combobox property or use the combobox.tag for it. Tag in itself has no meaning and is meant for usage as some spare property, if you don't have a combobox class you can or want to extend with a property, but put a basic, native combobox on your form, then the tag is available for such things.

So eg start with combobox1.tag="noinfo", in dropdown set it to "info" and in lostfocus to "noinfo" again, in valid do the info form depending on the tag value.

Bye, Olaf.
 
Indeed Tamar, I could have used a new form property or like Olaf said a tag in the combobox that would have been even better.

Usually I use form properties instead of public, but I think I want it to do it fast, so i used bad public variable for that.

I will change it to a tag because i only need it in the combobox.

Thanks guys to put me back in the right way of programming


TheBlainer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top