Dynamic ComboBox

HMG Samples and Enhancements

Moderator: Rathinagiri

Post Reply
User avatar
esgici
Posts: 4513
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Has thanked: 389 times
Been thanked: 111 times
Contact:

Dynamic ComboBox

Post by esgici » Tue Oct 07, 2008 4:58 pm

Hi all

I have tried a "Dynamic" ComboBox. Dynamic means changeable at runtime.

The code is here :

Code: Select all

/*
   HMG Dynamic ComboBox Demo

   (c) 2008 Bicahi Esgici
   
*/

#include "minigui.ch"
        
#define CMBMAXITCOUNT 10
  
Function Main

    PRIV aSrcStrgs := { '' }
    
    DEFINE WINDOW Form_1 ;
        AT 0,0 ;
        WIDTH 400 ;
        HEIGHT 200 ;
        TITLE 'Dynamic ComboBox Demo' ;
        MAIN

      ON KEY ESCAPE ACTION Form_1.Release

        @ 10,10 COMBOBOX Combo_1 ;
            WIDTH  200  ;
            HEIGHT 200 ;
            ITEMS aSrcStrgs ;
            VALUE 1 ;
            DISPLAYEDIT ;
            ON LOSTFOCUS DynCmbDone() ;
            ON ENTER  DynCmbDone() ;
            DROPPEDWIDTH 250
            
        @ 10,230 TEXTBOX txbDummy         // For forcing combo to lostfocus
            
    END WINDOW

    CENTER WINDOW Form_1

    ACTIVATE WINDOW Form_1

RETURN // Main()

*-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._


PROC DynCmbDone()

   IF Form_1.Combo_1.Value == 0 .AND. !EMPTY( Form_1.Combo_1.DisplayValue )       
      IF LEN( aSrcStrgs ) <= CMBMAXITCOUNT
         AADD( aSrcStrgs,  )
      ENDIF    
      AINS( aSrcStrgs, 1 )
      aSrcStrgs[ 1 ] := ''
      aSrcStrgs[ 2 ] := Form_1.Combo_1.DisplayValue
      Form_1.Combo_1.DeleteAllItems()
      AEVAL( aSrcStrgs, { | c1 | Form_1.Combo_1.AddItem( c1 ) } )
      Form_1.Combo_1.Value := 2
   ENDIF   

RETU // DynCmbDone()

*-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._
I am not sure that this is the best way and I hope that may be many betters.

Any opinion ?

Regards

--

esgici
Viva INTERNATIONAL HMG :D

User avatar
Rathinagiri
Posts: 5263
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Has thanked: 169 times
Been thanked: 172 times
Contact:

Post by Rathinagiri » Sat Feb 05, 2011 7:52 pm

I am sorry that I had not seen this thread. :(

Thanks a lot Esgici for giving the link.

I like your idea a lot.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.

User avatar
esgici
Posts: 4513
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Has thanked: 389 times
Been thanked: 111 times
Contact:

Post by esgici » Sat Feb 05, 2011 8:35 pm

Hi Rathi
rathinagiri wrote:I am sorry that I had not seen this thread. :(
Please don't worry my friend; really there isn't any problem by my side.
rathinagiri wrote:I like your idea a lot.
The important is that, thank you very much. :D

Regards

--

Esgici
Viva INTERNATIONAL HMG :D

Post Reply