How to avoid a ComboBox to change item in special cases?

How to avoid a ComboBox to change item in special cases?

Post by » Sat, 25 Mar 2006 14:37:45


I have cases when a user should confirm, if he really wants to change
the item of a TComboBox and if he denies, the change should be not
done.

I used the ComboBox to define some predefined constellations and if
the user himself modified this constellation the Text-property in the
ComboBox turn to something like 'user-modified'. If he now wants to
select a predefined ComboBox-constellation he is asked to confirm.

So I was looking for an event in TComboBox, which allows to reverse a
change, but did not find one.

So I used OnMouseEnter to remember the old-value of the ComboBox's
Text field and OnSelect to proof this old value (here the ComboBox
already contains the new one). So I could check, if the old text is
'used-modified' and if it is I can ask him to confirm. If he denies...

...I want to restore the old text-value, but even after changing it in
the OnSelect-event it has been changed back as soon as the user got
control over it.

It seems that changing ItemIndex would work to change the ItemIndex
(and set the text appropriate to the ItemIndex, but unfortunately
'user-modified' is no (and should not be) a choosable ComboBox-Item.

In which event can I avoid the user-choice at best?
And if I can't: Is there a way to change the Text-property value back
inside an event?

Thanks,

Michael
 
 
 

How to avoid a ComboBox to change item in special cases?

Post by » Sat, 25 Mar 2006 14:39:08

OOps, soory. Wrong newsgroup.
I repost it to vcl...

Michael