Combobox control

HMG en Español

Moderator: Rathinagiri

Post Reply
Georg_BA
Posts: 106
Joined: Fri Apr 07, 2017 5:31 pm
DBs Used: DBF

Combobox control

Post by Georg_BA »

good day to all,

I have a question, it is possible to set some items to read only as when radiogroup

DEFINE COMBOBOX CB_1
ROW 10
COL 10
WIDTH 140
HEIGHT 25
ITEMS { 'EN','ES','SK','PL' }
READONLY { .F. , .T. , .F. , .T. }
VALUE 1
END COMBOBOX


DEFINE RADIOGROUP Radio_1
OPTIONS { 'One' , 'Two' , 'Three', 'Four' }
VALUE 1
WIDTH 100
TOOLTIP 'RadioGroup'
READONLY { .F. , .T. , .F. , .T. }
ROW 10
COL 10
END RADIOGROUP


Thanks for help
User avatar
serge_girard
Posts: 3161
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: Combobox control

Post by serge_girard »

Hi Georg,

I doubt if it possible. Documentation doesn't mention.
What you can do is deleting all items and re-add with items (true), a bit tricky.

Serge
There's nothing you can do that can't be done...
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: Combobox control

Post by esgici »

Please look at DISPLAYEDIT property :arrow:

As soon as I remember .F. value means "Read Only" and default value of this property is .F.

Attention: <lValue> usable in alternate ( DEFINE ... ENDDEFINE) syntax; @ x, y syntax not accept <lValue>; using only keyword means .T.

My little sample Dynamic Combobox may be useful.

Happy HMG'ing :D
Viva INTERNATIONAL HMG :D
User avatar
serge_girard
Posts: 3161
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: Combobox control

Post by serge_girard »

You can use this :

Code: Select all

#include "hmg.ch"
 

FUNCTION MAIN()
/**************/
DEFINE WINDOW Form_1 ; 
   AT 0,0	           ;
   WIDTH  550	;  
   HEIGHT 300  ;
   TITLE 'Languages'  ;
   ICON  ""	;
   MAIN

   ON KEY ESCAPE  ACTION Form_1.Release  



   DEFINE RADIOGROUP Radio_1
      OPTIONS { 'Roman' , 'Germanic' , 'Slavic', 'Turkish' }  /* etcera */	
      VALUE 1
      WIDTH 100
      TOOLTIP 'Languages'
      ROW 10
      COL 10
      ON CHANGE Fill_CB_1()
   END RADIOGROUP


   DEFINE COMBOBOX CB_1
      ROW 10
      COL 120
      WIDTH 140
      HEIGHT 25
      ITEMS {'FR',  'ES' ,   'IT' }  // DEFAULT
      VALUE 1
   END COMBOBOX

END WINDOW 


Form_1.center
Form_1.activate

RETURN NIL






FUNCTION Fill_CB_1()
/******************/

Form_1.CB_1.DeleteAllItems()
DO CASE 
CASE Form_1.Radio_1.Value == 1 // ROMAN
   Form_1.CB_1.AddItem( 'FR' )
   Form_1.CB_1.AddItem( 'ES' )
   Form_1.CB_1.AddItem( 'IT' )

CASE Form_1.Radio_1.Value == 2 // GERMANIC
   Form_1.CB_1.AddItem( 'DE' )
   Form_1.CB_1.AddItem( 'EN' )
   Form_1.CB_1.AddItem( 'NL' )

CASE Form_1.Radio_1.Value == 3 // SLAVIC
   Form_1.CB_1.AddItem( 'SK' )
   Form_1.CB_1.AddItem( 'RU' )
   Form_1.CB_1.AddItem( 'BU' )

CASE Form_1.Radio_1.Value == 4 // TURKISH
   Form_1.CB_1.AddItem( 'TR' )

OTHERWISE
   /* etcera */	
ENDCASE
Form_1.CB_1.Value := 1
RETURN

Serge
There's nothing you can do that can't be done...
Georg_BA
Posts: 106
Joined: Fri Apr 07, 2017 5:31 pm
DBs Used: DBF

Re: Combobox control

Post by Georg_BA »

Thank you, I'll try Dynamic ComboBox
The delete solution does not suit me, I created a condition based on the COMBOBOX.value return value. In some parts, I need only 1 value active but the value should be 5
Post Reply