ComboBox, remove highlight after selection

2016r1 on windows7:

After selecting a new text line in the ComboBox all text is highlighted windows std highlight blue.
How can this be removed and still keeping the caret at the end of the text ?

Hitting Right Arrow after selecting a new line gives me what I want in the CB

http://documentation.xojo.com/index.php/ComboBox

According to the documentation ComboBox behaves similarly to a TextField.
Try setting the SelStart to the last character, and SelLength to 0.

Emphasis on I have not tried it, only checked the docs. Results may vary.

In the change event of your ComboBox

me.SelStart = len(me.Text)

Sellength Es macht nichts!

No, whole text is still blue…

Then either A) I don’t understand what you want, or B) some other event is happening in your combobox.

If you’re talking about how it selects the text when you hit Enter you’ll need to use KeyDown/KeyUp to test for that key, other than that Roger’s solution works.

Demo Project

Tim, Part of the problem may be if we’re on different systems. I’m on MS Win.

Got it working perfectly, although somewhat messy because I had to use a Timer.

It looks like SelStart and SelLength have no effect if used inside the CB control

Working code:

Project: ComboBox_Override_WORKING_OK
Date: 22. juni 2016 20:25:08
Window1
Class Window1
Inherits Window
Methods
Sub Remove_that_damn_CB_Autoselection()
cbTest.SelStart=len (cbTest.Text)
cbTest.SelLength=0
End Sub
Window1 Control PB_selectiontest:
Sub Action()
'test: select approx 1/3 of the text
cbTest.SelStart=len (cbTest.Text)/2
cbTest.SelLength=len (cbTest.Text)/3
End Sub
Window1 Control Timer1:
Sub Action()
Window1.Remove_that_damn_CB_Autoselection
End Sub
Window1 Control cbTest:
Sub Change()
timer1.Mode=0
timer1.Period=1
timer1.Reset
timer1.Enabled=True
End Sub
Sub Open()
'' fill terminal listbox with the most used commands
Me.AddRow("$:config_anpol=")
Me.AddRow("$:config_dirpol=")
Me.AddRow("$:config_encmul=")
Me.AddRow("$:config_indexwidth=")
Me.AddRow("$:config_input=")
Me.AddRow("$:config_jogcoarse=")
Me.AddRow("$:config_jogfine=")
Me.AddRow("$:config_mode=")
Me.AddRow("$:config_motor=")
Me.AddRow("$:config_motpol=")
Me.AddRow("$:config_pid=")
Me.AddRow("$:config_reset")
Me.AddRow("$:config_save")
Me.AddRow("$:config_stepgear=")
Me.AddRow("$:config_steppol=")
Me.AddRow("$:config_sysgain=")
Me.AddRow("$:config_tacc=")
Me.AddRow("$:config_tvel=")
Me.AddRow("$:move_")
Me.AddRow("$:config_")
Me.AddRow("$:config_save")
Me.AddRow("$:config_save")
window1.Remove_that_damn_CB_Autoselection
End Sub
End Class

Very nice use of a timer. The SelStart and SelLength do have effect inside the CB, but the system (WIN in this case) seems to “refresh” the control afterwards and the selection is always on. If right after selection you move the focus away from the control, the SelStart / SelLength do work, but then you no longer are on the CB. Your solution, I think, addresses this.