ListBox
Previous topic  First topic  Next topic





Define and Properties


Properties
Status
Default
Planned
Started
Ready
Comments
CREATE LISTBOX 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.
      [ 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
      [ ENABLED .T. | .F. ]
.T.
  
Enable or Disable control. You can use this property to set/get ENABLED an item by coding it in that way:
mg_set( <cWindow> , <cControl> , <nItem> , .T. | .F. )
mg_get( <cWindow> , <cControl> , <nItem> )
      [ 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
      [ MULTISELECT .T. | .F. ]
.F.
  
It allow user to select one or more items
      [ SELECTALL .T. | .F. ]
n/a
  
Select or unSelect all items of ListBox control when MultiSelect .T. was used
      [ VALUE nValue ]
1
  
Item to display. If MULTISELECT clause is used VALUE must be a numeric array, containing the index position of selected items.
      [ SORT .T. | .F. ]
.F.
  
Sort Item Lists before display it
      [ DISPLAYEDIT .T. | .F. ]
.F.
  Allow edit the selected item
      [ NOTABSTOP .T. | .F. ]
.F.
  
This property force that TAB key doesn't stop in this control
      [ 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.
      [ 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
      [ ONSELECTIONCHANGE cOnSelectionChange | {BOnSelectionChange} ]
NIL
  
An action to be performed when items selected 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
      [ ONCLICK cOnClick | {BOnClick} ]
NIL
  
An action to be performed when control is clicking
      [ ONDBLCLICK cOnDblClick | {BOnDblClick} ]
NIL
  
An action to be performed when user press double mouse click
      [ VISIBLE .T. | .F. ]
.T.
  
Show or hide control (like methods SHOW and HIDE)
      [ 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.
      [ CONTEXTMENUSUPRESSED .T. | .F. ]
.F.
  
Disable the display of the Context Menu of control.
      [ CREATE CONTEXT MENU [ cName ] ]   
CONTEXT MENU for control
            [ ......... ]   
You can see properties for this menu in CONTEXT MENU topic
      [ END MENU ]   
 
END LISTBOX 

Jump to Context Menu topic



Methods


Methods
Status
Default
Planned
Started
Ready
Comments
    HIDE
n/a
  
This method HIDE the control
    SHOW
n/a
  
This method SHOW the control
    SELECT aItems
n/a
  
Select all items of aItems for a ListBox when MULTISELECT .T. was used
    SELECTALL
n/a
  
Select all items of a ListBox when MULTISELECT .T. was used
    UNSELECT aItems
n/a
  
UnSelect all items of aItems for a ListBox when MULTISELECT .T. was used
    UNSELECTALL
n/a
  
Unselect all items of a ListBox when MULTISELECT .T. was used
    ISSELECT nItem
n/a
  
Check if nItem is select or not
    GETLASTITEMCLICKED
n/a
  
Return the position of last item clicked (selected or unselected)
    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
    SORT
n/a
  
Sort control content in ascending order
    ADDITEM 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
    ONCHANGE
n/a
  
Execute ONCHANGE block coded in CREATE or seted by mg_Set
    ONSELECTIONCHANGE
n/a
  
Execute ONSELECTIONCHANGE 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
    ONCLICK
n/a
  
Execute ONCLICK block coded in CREATE or seted by mg_Set
    ONDBLCLICK
n/a
  
Execute ONDBLCLICK block coded in CREATE or seted by mg_Set
    ONENTER
n/a
  
Execute ONENTER block coded in CREATE or seted by mg_Set



Example:

File: d_listbox.prg


#include "marinas-gui.ch"

Function main()

   SET APPLSTYLE TO "MarinasLooks"

   Request DBFCDX , DBFFPT
   Rddsetdefault( "DBFCDX" )

   CreateDataBaseListBox()
   UseDataBaseListBox()

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

      d_listbox_def()

   END WINDOW

   mg_Do( "d_window" , "center" )

   mg_Do( "d_window" , "activate" )

   CloseDataBaseListBox()
   EraseDataBaseListBox()

Return .T.


File: d_listbox_def.prg

#include "marinas-gui.ch"

Function d_listbox_def()

     CREATE LABEL List_1_Label
            ROW    19
            COL    150
            HEIGHT 20
            VALUE  ""
            FONTSIZE 12
            WIDTH  139
            FONTITALIC .T.
            FONTCOLOR {0,0,255}
     END LABEL

     CREATE LISTBOX List_1
            ROW    40
            COL    150
            WIDTH  139
            HEIGHT 176
            ITEMS {"Red","Blue","White","Black","Pink","Green"}
            VALUE 3
            FONTNAME "mg_monospace"
            FONTSIZE 14
            TOOLTIP "ListBox with FONTNAME, FONTBOLD and FONTSIZE"
            FONTCOLOR {255,255,255}
            FONTBOLD .T.
            BACKCOLOR {0,0,255}
            ONDBLCLICK mg_MsgInfo( "Item (dblclick): " + mg_AllStr( mg_Get( "d_window" , "List_1" , "value" ) ) )
            ONENTER    mg_MsgInfo( "Item (enter): " + mg_AllStr( mg_Get( "d_window" , "List_1" , "value" ) ) + " (" + mg_Get( "d_window" , "List_1" , "item" , mg_Get( "d_window" , "List_1" , "value" ) ) + ")" )
            ONCHANGE   mg_Set( "d_window" , "List_1_Label" , "value" , mg_Get( "d_window" , "List_1" , "item" , mg_Get( "d_window" , "List_1" , "value" ) ) )

            CREATE CONTEXT MENU

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

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

            END MENU

     END LISTBOX

     mg_Do( "d_window" , "List_1" , "onchange" )

     CREATE LISTBOX List_2
            ROW    40
            COL    330
            WIDTH  119
            HEIGHT 179
            MULTISELECT .T.
            ITEMS {"Pritpal Bedi","Viktor Szakáts","Przemyslaw Czerpak","Bruno Luciani","CarozoDeQuilmes"}
            VALUE { 2 , 4 }
            TOOLTIP "ListBox with MULTISELECT and FONTUNDERLINE"
            BACKCOLOR {135,218,61}
            ONENTER    mg_MsgInfo( "Items: " + mg_AllStr( mg_Get( "d_window" , "List_2" , "value" ) ) )
     END LISTBOX

     CREATE LISTBOX List_3
            ROW    40
            COL    490
            WIDTH  177
            HEIGHT 349
            ITEMS {'List_33','List_22','List_13','List_34','List_12','List_75','List_34','List_98','List_wt','List_30','List_xx','List_14','List_00','List_23','List_32','List_56','List_34','List_87','List_67','List_09','List_28','List_54','List_36','List_27','List_32'}
            VALUE 5
            TOOLTIP "ListBox with FONTCOLOR, FONTITALIC and SORT"
            BACKCOLOR {247,206,240}
            FONTCOLOR {0,0,255}
            SORT .T.
            ONENTER    mg_MsgInfo( "Item: " + mg_AllStr( mg_Get( "d_window" , "List_3" , "value" ) ) + " (" + mg_Get( "d_window" , "List_3" , "item" , mg_Get( "d_window" , "List_3" , "value" ) ) + ")" )
     END LISTBOX

     CREATE IMAGE List_4Image
        ROW       300
        COL       105
        WIDTH     32
        HEIGHT    32
        PICTURE   "../resource/d_focus_off.png"
        TOOLTIP   "ListBox Focus"
     END IMAGE

     CREATE LISTBOX List_4
            ROW    260
            COL    150
            WIDTH  298
            HEIGHT 127
            ITEMS {"Poland","India","Argentina","Bulgary","Hungary"}
            ITEMSICONS  {"../resource/d_banner_poland.png","../resource/d_banner_india.png","../resource/d_banner_argentina.png","../resource/d_banner_bulgary.png","../resource/d_banner_hungary.png"}
            VALUE 3
            TOOLTIP "Standard ListBox"
            ONENTER    mg_MsgInfo( "Item: " + mg_AllStr( mg_Get( "d_window" , "List_4" , "value" ) ) + " (" + mg_Get( "d_window" , "List_4" , "item" , mg_Get( "d_window" , "List_4" , "value" ) ) + ")" )
            ONGOTFOCUS mg_Set( "d_window" , "List_4Image" , "picture" , "../resource/d_focus_on.png" )
            ONLOSTFOCUS mg_Set( "d_window" , "List_4Image" , "picture" , "../resource/d_focus_off.png" )
     END LISTBOX

Return .T.

Function CreateDataBaseListbox()
   Local nInx
   Local aStruct := { ;
            { "code", "N", 5, 0 }, ;
            { "name", "C", 30, 0 }, ;
            { "telephone", "C", 13, 0 }, ;
            { "address", "C", 30, 0 }, ;
            { "city", "C", 30, 0 }, ;
            { "date", "D", 8, 0 } ;
            }
   Local aData := { ;
            {1,"Bruno Luciani","0054349588585","Colon 2323","Ramallo",date()}, ;
            {2,"Roberto Fontana","003489384988","Via Benneto 456","Roma",date()}, ;
            {3,"Francesco Perillo","004568989899","Via Romana 8989","Florence",date()}, ;
            {4,"Andres Calamaro","0084758234","Fuenteovejuna 213","Madrid",date()}, ;
            {5,"Edelmiro Molinari","009393948722","Scout 1234","Los Angeles",date()}, ;
            {6,"Gabriela Parodi","003922899844","Arce 2132 P1 A","Buenos Aires",date()}, ;
            {7,"Carozo de Quilmes","0054382390849","Urquiza 321","Quilmes",date()} ;
            }
   hb_dbDrop( "d_listbox_" + mg_GetThreadName() )
   dbCreate( "d_listbox_" + mg_GetThreadName() , aStruct )
   dbUseArea( .T. , , "d_listbox_" + mg_GetThreadName() , "d_listbox" )
   for nInx:=1 to len( aData )
      d_listbox->(dbappend())
      d_listbox->code:=aData[nInx,1]
      d_listbox->name:=aData[nInx,2]
      d_listbox->telephone:=aData[nInx,3]
      d_listbox->address:=aData[nInx,4]
      d_listbox->city:=aData[nInx,5]
      d_listbox->date:=aData[nInx,6]
      d_listbox->(dbcommit())
   next
   close d_listbox
return .T.

Function UseDataBaseListbox()
   dbUseArea( .T. , , "d_listbox_" + mg_GetThreadName() , "d_listbox" )
   index on d_listbox->code tag "code01" to ( "d_listbox_" + mg_GetThreadName() )
Return .T.

Function CloseDataBaseListbox()
   close d_listbox
Return .T.

Function EraseDataBaseListbox()
   hb_dbDrop( "d_listbox_" + mg_GetThreadName() )
Return .T.



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


---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
last update: April 27
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

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

www.marinas-gui.org


www.marinas-gui.org  

Previous topic  First topic  Next topic