ComboBox
Previous topic  First topic  Next topic





Define and Properties


Properties
Status
Default
Planned
Started
Ready
Comments
CREATE COMBOBOX cName | (cVarName) | &(cExpression) 
      [ ; OF cWindow | (cVarName) | &(cExpression) ]
Parent.Name
  
A reference to the Parent Window
      [ ROW nRow ]
0
  
Row position on container window in pixels coordinates
      [ COL nCol ]
0
  
Col position on container window in pixels coordinates
      [ WIDTH nWidth ]
?
  
The desired width size of the Control in pixels
      [ HEIGHT nHeight ]
?
  
The desired height size of the Control in pixels
      [ ROWBOTTOM nRow ]
n/a
  
Bottom Row position on container window in pixels coordinates. This property adjust the HEIGHT property according the ROW property.
      [ COLRIGHT nCol ]
n/a
  
Right Col position on container window in pixels coordinates. This property adjust the WIDTH property according the COL property.
      [ DISPLAYEDIT .T. | .F. ]
.F.
  
Allows user to edit selected item text in display area
      [ DISPLAYVALUE cValue ]
NIL
  
Set or Get edit value. Enable it by DISPLAYEDIT
      [ ENABLED .T. | .F. ]
.T.
  
Enable or Disable control
      [ ITEM nItem [ , cText ] ]
NIL
  
Value text of item nItem (ONLY available for mg_Get() and mg_Set() functions)
      [ ITEMICON nItem , cIconName ]
NIL
  
Icon name for item nItem. The item must already exist. (ONLY available for mg_Get() and mg_Set() functions)
      [ ITEMS aItemsTexts ]
NIL
  
An array with control items
      [ ITEMSICONS aItemsIconNames ]
NIL
  
An array with icons for control items
      [ ITEMCOUNT ]   
Only for mg_Get() function. It returns the total amount of items in control
      [ ITEMSOURCE cFiledName ]
NIL
  
Filled the control with the content of a table field. The table must already be open. When ITEMSOURCE property is set to a fieldname, 'Value' property uses the physical record number, as in browse.
      [ MAXVISIBLEITEMS nMaxVisibleItems ]
11
  
This property holds the maximum allowed size on screen of the combo box, measured in items. This property doesn't work in CleanLooks and MarinasLooks Styles
      [ AUTOSIZE .T. | .F. ]
.F.
  
Auto adjust control size to text
      [ FONTNAME "cFontName" ]
Parent.Fontname
  
Font family for control text
      [ FONTSIZE nPoints ]
Parent.FontSize
  
Font size for control text
      [ FONTBOLD .T. | .F. ]
.F.
  
Set Bold attribute to control text
      [ FONTITALIC .T. | .F. ]
.F.
  
Set Italic attribute to control text
      [ FONTUNDERLINE .T. | .F. ]
.F.
  
Set Underline attribute to control text
      [ FONTSTRIKEOUT .T. | .F. ]
.F.
  
Set Strikeout attribute to control text
      [ FONTCOLOR {aFontColor} | aVarFontColor ]
OS.FontColor
  
Set foreground color (text color)
      [ BACKCOLOR {aBackColor} | aVarBackColor ]
OS.BackColor
  
Set background color
      [ TOOLTIP cToolTip ]
NIL
  
Text for display into tooltip
      [ ALIGN nAlign ]
Qt_AlignLeft
 
 Align text, most common value are Qt_AlignLeft , Qt_AlignCenter and Qt_AlignRight
      [ VALUE nValue ]
1
  
Item number to display or item number selected (for mg_Get())
      [ VALUESOURCE cFieldName ]
NIL
  
This option should be used in conjunction with ITEMSOURCE and the content of fieldname is used instead the physical record number.
      [ LISTWIDTH nListWidth ]
?
  ?
      [ GRIPPERTEXT ? ]
?
  ?
      [ SORT .T. | .F. ]
.F.
  
Sort Items control in ascending order.
      [ PARENT cControlParent ]   
Get or Set the control name of parent widget
      [ PARENTTYPE n/a ]   
Only for mg_get() function, this property returns the PARENT control type or "" if the parent was not set.
      [ NOTABSTOP .T. | .F. ]
.F.
  
This property force that TAB key doesn't stop in this control
      [ PERMANENT .T. | .F. ]
.F.
  
Only for controls defined into STATUSBAR. This property force this control as permanent statusbar message. Control will be placed at right corner of statusbar and it is never hidden. Used for important mode indications, for example, some applications put a Caps Lock indicator in the status bar.
      [ FORCEACTION .T. | .F. ]
.F.
  
It force the execution of the actions defined by methods like ACTION, ONENTER, ONCLICK, ONDBLCLICK, etc. when NOTABSTOP property was set '.T.'. This property is useful when application focus is over a control when a VALID clause and it doesn't permit lostfocus.
      [ ONCHANGE cOnChange | {BOnChange} ]
NIL
  
An action to be performed when control value is changed
      [ ONENTER cOnEnter | {BOnEnter} ]
NIL
  
An action to be performed when user press ENTER or RETURN keys. You can interrupt the ENTER key propagate to the control returning the __MG_KEY_NO_PROPAGATE constant, e.g. to disable ENTERTAB behavior.
      [ ONGOTFOCUS cOnGotFocus | {BOnGotFocus} ]
NIL
  
An action to be performed when control is focused
      [ ONLOSTFOCUS cOnLostFocus | {BOnLostFocus} ]
NIL
  
An action to be performed when control is lost focused
      [ VISIBLE .T. | .F. ]
.T.
  
Show or hide control (like methods SHOW and HIDE)
      [ HASFOCUS ]   
Only for mg_Get() function. This property returns .T. if control has the application focus
      [ CURSOR ]
Qt_ArrowCursor
  
Change the cursor pointer shape for the control. Go to to learn more about it.
      [ CREATE CONTEXT MENU [ cName ] ]   
CONTEXT MENU for control
            [ ......... ]   
You can see properties for this menu in CONTEXT MENU topic
      [ END MENU ]   
 
END COMBOBOX 

Jump to Context Menu topic



Methods


Methods
Status
Default
Planned
Started
Ready
Comments
    ADDITEM nItem , cText
NIL
  
Insert a new item to control. When the item was added, you can add ICON to item by ITEMICON property (mg_Set() function)
    DELETEITEM nItem
NIL
  
Delete item number nItem from control
    DELETEALLITEMS
n/a
  
Delete ALL items from control
    SORT
n/a
  
Sort control content in ascending order
    HIDE
n/a
  
This method HIDE the control
    SHOW
n/a
  
This method SHOW the control
    UNSETCURSOR
n/a
  
Reset the cursor pointer shape for the control to default (Qt_ArrowCursor). Go to to learn more about it.
    RELEASE
n/a
  
This method is used to destroy the control.
    SETFOCUS
n/a
  
This method put the program focus into control
    ONCHANGE
n/a
  
Execute ONCHANGE block coded in CREATE or seted by mg_Set
    ONENTER
n/a
  
Execute ONENTER block coded in CREATE or seted by mg_Set
    ONGOTFOCUS
n/a
  
Execute ONGOTFOCUS block coded in CREATE or seted by mg_Set
    ONLOSTFOCUS
n/a
  
Execute ONLOSTFOCUS block coded in CREATE or seted by mg_Set



Example:

File: d_combobox.prg


#include "marinas-gui.ch"

MEMVAR cComboBoxName
MEMVAR nNumber

Function main()

   PRIVATE cComboBoxName := "d_combobox"
   PRIVATE nNumber     := 33

   SET APPLSTYLE TO "MarinasLooks"

   Request DBFCDX , DBFFPT
   Rddsetdefault( "DBFCDX" )

   CreateDataBaseComboBox()
   UseDataBaseComboBox()

   CREATE WINDOW d_window
      ROW 0 ; COL 0
      WIDTH 820 ; HEIGHT 480
      CAPTION "Marinas-GUI Sample for ComboBox Control"
      ICON "../resource/d_test.ico"
      BACKCOLOR {216,237,236}
      MAIN .T.

      d_combobox_def()

   END WINDOW

   mg_Do( "d_window" , "center" )

   mg_Do( "d_window" , "activate" )

   CloseDataBaseComboBox()
   EraseDataBaseComboBox()

Return .T.


File: d_combobox_def.prg

#include "marinas-gui.ch"

Function d_combobox_def()

      CREATE COMBOBOX Combo_1
             ROW    60
             COL    190
             WIDTH  330
             HEIGHT 24
             ITEMS {"Argentina" , "India" , "Albany" , "Bulgary" , "Italy" }
             ITEMSICONS { "../resource/d_banner_argentina.png" , "../resource/d_banner_india.png" , "../resource/d_banner_albany.png" , "../resource/d_banner_bulgary.png" , "../resource/d_banner_italy.png" }
             VALUE 1
             TOOLTIP "ComboBox with FontBold, FontItalic and FontUnderline and ITEMICON"
             FONTBOLD .T.
             FONTITALIC .T.
             FONTUNDERLINE .T.

             CREATE CONTEXT MENU

                CREATE ITEM "Item 1 from ComboBox"
                   ONCLICK { || mg_MsgInfo( "Item 1 from ComboBox" ) }
                   PICTURE "../resource/d_test.png"
                END ITEM

                CREATE ITEM "Item 2 from ComboBox"
                   ONCLICK { || mg_MsgInfo( "Item 2 from ComboBox" ) }
                   PICTURE "../resource/d_test.png"
                END ITEM

             END MENU

      END COMBOBOX

      CREATE BUTTON Combo_1Button
             ROW    60
             COL    540
             WIDTH  100
             HEIGHT 24
             CAPTION "Sort Items"
             TOOLTIP "Sort Items of ComboBox"
             FONTBOLD .T.
             FONTITALIC .T.
             ONCLICK ( mg_Do( "d_window" , "Combo_1" , "sort" ) , mg_MsgInfo( "Items sorted !!!" ) )
      END BUTTON

      CREATE COMBOBOX &( M->cComboBoxName + "__" + alltrim( str( M->nNumber ) ) )
             ROW    130
             COL    190
             WIDTH  330
             HEIGHT 24
             ITEMS {"Bruno" , "Pritpal" , "Viktor" , "CarozoDeQuilmes" }
             FONTNAME "mg_monospace"
             FONTSIZE 14
             TOOLTIP "ComboBox with BackColor, FontColor, FontName mg_monospace and FontSize"
             FONTCOLOR {3,7,182}
             VALUE 1
             BACKCOLOR {243,65,91}
        //   ONCHANGE mg_MsgInfo( "Item: " + mg_AllStr( mg_Get( "d_window" , M->cComboBoxName + "__" + alltrim( str( M->nNumber ) ) , "value" ) ) )
             ONGOTFOCUS mg_Set( "d_window" , M->cComboBoxName + "__" + alltrim( str( M->nNumber ) ) + "Label" , "value" , "Focused !!!" )
             ONLOSTFOCUS mg_Set( "d_window" , M->cComboBoxName + "__" + alltrim( str( M->nNumber ) ) + "Label" , "value" , "Without Focus" )
      END COMBOBOX

      CREATE LABEL &( M->cComboBoxName + "__" + alltrim( str( M->nNumber ) ) + "Label" )
             ROW    130
             COL    540
             WIDTH  100
             HEIGHT 24
             FONTCOLOR {0,0,255}
             VALUE "Without Focus"
      END LABEL

      DbSelectArea( "d_combobox" )

      CREATE COMBOBOX Combo_3
             ROW    200
             COL    190
             WIDTH  150
             HEIGHT 24
             VALUESOURCE d_combobox->code
             ITEMSOURCE country
             VALUE 24
             TOOLTIP "ComboBox width ItemSource"
             ONCHANGE mg_MsgInfo( "Item: " + mg_AllStr( mg_Get( "d_window" , "Combo_3" , "value" ) ) + " With: " + ComboboxGetCountry( mg_Get( "d_window" , "Combo_3" , "value" ) ) )
      END COMBOBOX

      CREATE LABEL Combo_3Label
             ROW    200
             COL    350
             WIDTH  360
             HEIGHT 24
             FONTCOLOR {0,0,255}
             FONTBOLD .T.
             VALUE  "ItemSource (From DBF table !!!)"
      END LABEL

      CREATE COMBOBOX Combo_4
             ROW    270
             COL    190
             WIDTH  150
             HEIGHT 24
             ITEMS { "Item B" , "Item A" , "Item C" }
             SORT .T.
             VALUE 1
             BACKCOLOR { 0,0,255 }
             FONTCOLOR { 255,255,255 }
             FONTBOLD .T.
             ONCHANGE mg_MsgInfo( "Item: " + mg_AllStr( mg_Get( "d_window" , "Combo_4" , "value" ) ) )
             TOOLTIP "ComboBox with Sort"
      END COMBOBOX

      CREATE LABEL Combo_4Label
             ROW    270
             COL    350
             WIDTH  360
             HEIGHT 24
             FONTCOLOR {0,0,255}
             FONTBOLD .T.
             VALUE  "Items sorted (SORT property/method)"
      END LABEL

      CREATE COMBOBOX Combo_5
             ROW    340
             COL    190
             WIDTH  150
             HEIGHT 24
             SORT .T.
             ITEMS {"Beta" , "Alpha" , "Gamma"}
             VALUE 3
             ONCHANGE mg_MsgInfo( "Item: " + mg_AllStr( mg_Get( "d_window" , "Combo_5" , "value" ) ) )
             DISPLAYEDIT .T.
             TOOLTIP "ComboBox width DisplayEdit"
      END COMBOBOX

      CREATE LABEL Combo_5Label
             ROW    340
             COL    350
             WIDTH  360
             HEIGHT 24
             FONTCOLOR {0,0,255}
             FONTBOLD .T.
             VALUE  "Edit Item (DISPLAYEDIT property)"
      END LABEL

      CREATE COMBOBOX Combo_6
             ROW    410
             COL    190
             WIDTH  150
             HEIGHT 24
             ITEMS { "50" , "49" , "48" , "47" , "46" , "45" , "44" , "43" , "42" , "41" , ;
                     "40" , "39" , "38" , "37" , "36" , "35" , "34" , "33" , "32" , "31" , ;
                     "30" , "29" , "28" , "27" , "26" , "25" , "24" , "23" , "22" , "21" , ;
                     "20" , "19" , "18" , "17" , "16" , "15" , "14" , "13" , "12" , "11" , ;
                     "10" , "09" , "08" , "07" , "06" , "05" , "04" , "03" , "02" , "01" }
             VALUE 1
             BACKCOLOR { 255,0,255 }
             FONTCOLOR { 255,255,255 }
             FONTBOLD .T.
             MAXVISIBLEITEMS 14
             ONCHANGE mg_MsgInfo( "Item: " + mg_AllStr( mg_Get( "d_window" , "Combo_6" , "value" ) ) + " with " + mg_Get( "d_window" , "Combo_6" , "item" , mg_Get( "d_window" , "Combo_6" , "value" ) ) )
             TOOLTIP "ComboBox with Long Item List (50 Items)"
      END COMBOBOX

      CREATE LABEL Combo_6Label
             ROW    410
             COL    350
             WIDTH  360
             HEIGHT 24
             FONTCOLOR {255,0,255}
             FONTBOLD .T.
             VALUE  "Long Item List with MaxVisibleItems has set to " + alltrim( str( mg_Get( "d_window" , "combo_6" , "maxVisibleItems" ) ) )
      END LABEL
//    CREATE LABEL Combo_6Label2
//           ROW    435
//           COL    350
//           WIDTH  360
//           HEIGHT 24
//           FONTSIZE 8
//           VALUE  "Warning: MaxVisibleItems doesn't work in FUSION Style"
//    END LABEL

Return .T.

Function CreateDataBaseComboBox()
   Local nInx
   Local aStruct := { ;
            { "code", "N", 5, 0 }, ;
            { "country" , "C", 30, 0 } ;
            }
   Local aData := { ;
            {13,"India-13"}, ;
            {25,"Bulgary-25"}, ;
            {52,"Italy-52"}, ;
            {24,"Brazil-24"}, ;
            {51,"Argentina-51"}, ;
            {17,"Liberia-17"}, ;
            {6,"Poland-6"} ;
            }
   hb_dbDrop( "d_combobox_" + mg_GetThreadName() )
   dbCreate("d_combobox_" + mg_GetThreadName() , aStruct )
   dbUseArea( .T. , , "d_combobox_" + mg_GetThreadName() , "d_combobox" )
   for nInx:=1 to len( aData )
      d_combobox->(dbappend())
      d_combobox->code:=aData[nInx,1]
      d_combobox->country:=aData[nInx,2]
   next
   close d_combobox
return .T.

Function UseDataBaseComboBox()
   dbUseArea( .T. , , "d_combobox_" + mg_GetThreadName() , "d_combobox" )
   index on d_combobox->code tag "code01" to ( "d_combobox_" + mg_GetThreadName() )
   index on d_combobox->country tag "country01" to ( "d_combobox_" + mg_GetThreadName() )
Return .T.

Function CloseDataBaseComboBox()
   close d_combobox
Return .T.

Function EraseDataBaseComboBox()
   hb_dbDrop( "d_combobox_" + mg_GetThreadName() )
Return .T.

Function ComboboxGetCountry( nCode )
   Local cAreaOld := dbf()
   DBSelectarea( "d_combobox" )
   d_combobox->( DBSetOrder( "code01" ) )
   d_combobox->( DBSeek( nCode ) )
   if !empty( cAreaOld )
      DBSelectarea( cAreaOld )
   endif
Return d_combobox->country



Marinas-GUI Version 03.06 and
Marinas-IDE Version 05.06 and
LEX Files Version 02.06


---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
last update: March 09
2017
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------




A Harbour/QT framework to make multiplatform programs

(©) Copyright 2009-2017 by Fernando Santolin (aka CarozoDeQuilmes)
CarozoDeQuilmes@gmail.com

2009-2017 Beta tester and full English translator: Bruno Luciani
Bruno.Luciani@gmail.com

2014-2015 Final English corrector: David Worboys
DavidWorboys@hotmail.com

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


Jump to Donation Topic


---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

www.marinas-gui.org


www.marinas-gui.org  

Previous topic  First topic  Next topic