xsharp.eu • Combobox - mark text and place cursor at the end in the SLE part of the CB
Page 1 of 1

Combobox - mark text and place cursor at the end in the SLE part of the CB

Posted: Sun Aug 01, 2021 4:58 pm
by buddla59
Hello,

after more than 10 years of abstinence from VO, I have to make some changes in an application (VO 2.8 SP4b) for my previous client.

Several combo boxes should be given an autofill function. This also works quite well so far. A text suggestion is written into the edit control of the combo box, only the cursor is placed at the beginning. However, the text change should be marked and the cursor should be placed at the end.

I implemented the search for a text suggestion in '__EditChange'.

Code: Select all

METHOD __EditChange() AS VOID PASCAL CLASS cmbAutoFill

   //
   // CurrenText in dem Item-Array suchen 
   //
   
   LOCAL dwItemNo    AS DWORD
   LOCAL cValue      AS STRING
   LOCAL dwLenValue  AS DWORD

   SUPER:__EditChange() 

   cValue     := SELF:CurrentText
   dwLenValue := SLen(cValue)

   IF SLen(cValue) > 0
      IF (dwItemNo := AScan(SELF:_aItemList, {|x| Upper(x) = Upper(cValue)})) > 0     
         SELF:CurrentText := AllTrim(SELF:_aItemList[dwItemNo])
      ENDIF 
   ENDIF

RETURN
How can I solve the problem?

Code: Select all

SELF:selection := Selection {dwOldCurPos, -1}
doesn't work or is not available.

Thanks for the help and sorry for my bad english.

Harry

Combobox - mark text and place cursor at the end in the SLE part of the CB

Posted: Mon Aug 02, 2021 5:35 am
by Karl-Heinz
Hi Harry,

You must send the selection to the edit control of the combobox.

Code: Select all

SELF:CurrentText := AllTrim(SELF:_aItemList[dwItemNo])
PostMessage( SELF:EditHandle , EM_SETSEL, 0 , -1 )   // <-------
regards
Karl-Heinz

Combobox - mark text and place cursor at the end in the SLE part of the CB

Posted: Mon Aug 02, 2021 2:38 pm
by buddla59
Hi Karl-Heinz,

thanks for the help. Works as it should.

regards
Harry