Select text in combo box text area on click?

R

Robin

Hi

How can I automatically select all text in a ComboBox text area when the
cursor is placed in that area? I can use SelStart and SelLength to do this
from a different control, but I cant find an appropriate ComboBox event to
do this. Got Focus only seems to work if the dropdown part of the box is
opened - (the event is triggered correctly by clicking the text area, but
having the cursor in the text seems to override SelStart and SelLength).

Alternatively, am I missing something in the ComboBox properties that would
give this behaviour anyway?

Regards

Robin
 
R

RoyVidar

Hi
How can I automatically select all text in a ComboBox text area when
the cursor is placed in that area? I can use SelStart and SelLength
to do this from a different control, but I cant find an appropriate
ComboBox event to do this. Got Focus only seems to work if the
dropdown part of the box is opened - (the event is triggered
correctly by clicking the text area, but having the cursor in the
text seems to override SelStart and SelLength).

Alternatively, am I missing something in the ComboBox properties that
would give this behaviour anyway?

Regards

Robin

Try the mouse up event of the combo.
 
R

Robin

RoyVidar said:
Try the mouse up event of the combo.
Mmm - MouseUp almost works. If the ComboBox gets focus by clicking in the
text area this works fine. But if the ComboBox gets focus by clicking the
arrow to expand the list, then MouseDown opens the list as expected, but the
MouseUp event procedure closes it again by moving focus to the text area.

Robin
 
R

RoyVidar

RoyVidar said:
Mmm - MouseUp almost works. If the ComboBox gets focus by clicking
in the text area this works fine. But if the ComboBox gets focus by
clicking the arrow to expand the list, then MouseDown opens the list
as expected, but the MouseUp event procedure closes it again by
moving focus to the text area.

Robin

I must confess, I haven't done that with combos. Perhaps if you allow
the selection when the mouse is within the text part? One suggestion
for
that, coule be trying to subtract the "arrow part".

if (x < me!cboMyCombo.Width - 75) then
' select the text
end if
 
R

Robin

I must confess, I haven't done that with combos. Perhaps if you allow
the selection when the mouse is within the text part? One suggestion for
that, coule be trying to subtract the "arrow part".

if (x < me!cboMyCombo.Width - 75) then
' select the text
end if
Absolutely spot on! Thank you Roy. (The arrow width is actually 275.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top