Elegir 2do elemento del Array de :SetCheck()

Elegir 2do elemento del Array de :SetCheck()

Postby FranciscoA » Wed Dec 09, 2020 9:50 pm

Amigos.
Elegir 2do elemento del Array de :SetCheck().
¿Alguno de ustedes puede suministrar un ejemplo de como se hace?

Pruebas:
Code: Select all  Expand view  RUN
local CASADO := "c:\fw1709\bitmaps\32x32\users.bmp"    
local  SOLTERO := "c:\fw1709\bitmaps\32x32\user.bmp"
local  SOLTERA := "c:\fw1709\bitmaps\32x32\mujer.bmp"  

WITH OBJECT oBrw
      //:married:SetCheck( { CASADO, SOLTERO } )   // Funciona...
      :married:SetCheck( { CASADO, if((oBrw:cAlias)->MF == "M", SOLTERO, SOLTERA) } )  // No funciona
      :CreateFromCode()
   END

Saludos.
Francisco J. Alegría P.
Chinandega, Nicaragua.

Fwxh-MySql-TMySql
User avatar
FranciscoA
 
Posts: 2159
Joined: Fri Jul 18, 2008 1:24 am
Location: Chinandega, Nicaragua, C.A.

Re: Elegir 2do elemento del Array de :SetCheck()

Postby FranciscoA » Wed Dec 09, 2020 10:28 pm

Aqui está un ejemplo completo:
Code: Select all  Expand view  RUN
#include "fivewin.ch"
REQUEST DBFCDX
//-----------------------------------------------//
function  Main()        //ShowingImg()
local aStruct := { {"First",    "C", 30,0},;
                   {"City",     "C", 30,0},;
                   {"Married",  "L", 30,0},;
                   {"MF",       "C",  1,0} }
   dbCreate(".\PEOPLE", aStruct)

   USE PEOPLE NEW SHARED ALIAS CUST VIA "DBFCDX"
   DbAppend()
   Field->first := "Maria"   ; field->City := "Managua" ; field->married := .f. ; field->mf := "F"  
   DbAppend()
   Field->first := "Olga"    ; field->City := "Leon" ;    field->married := .f. ; field->mf := "F"  
   DbAppend()
   Field->first := "Roberto" ; field->City := "Managua" ; field->married := .f. ; field->mf := "M"  
   DbAppend()
   Field->first := "Lucia"    ; field->City := "Managua" ; field->married := .f. ; field->mf := "F"  
   DbAppend()
   Field->first := "Martha"  ; field->City := "Managua" ; field->married := .t. ; field->mf := "F"  
   DbAppend()
   Field->first := "Miriam"  ; field->City := "Leon"    ; field->married := .t. ; field->mf := "F"  
   DbAppend()
   Field->first := "Nestor"  ; field->City := "Leon"    ; field->married := .t. ; field->mf := "M"  

   Sample00()

   CUST->(DBCLOSEAREA())
   Ferase(".\PEOPLE.DBF")

return nil

//-----------------------------------------------//
function Sample00()
local oDlg, oBrw
local CASADO  := "c:\fwh1709\bitmaps\32x32\users.bmp"    
local SOLTERO := "c:\fwh1709\bitmaps\32x32\user.bmp"
local SOLTERA := "c:\fwh1709\bitmaps\32x32\mujer.bmp"  //agregado a la carpeta

   DEFINE DIALOG oDlg SIZE 600,400 PIXEL TRUEPIXEL

   @ 10,10 XBROWSE oBrw SIZE -10,-10 PIXEL OF oDlg ;
      DATASOURCE "CUST" ;
      COLUMNS "FIRST", "CITY", "MARRIED", "MF" ;
      CELL LINES NOBORDER

  WITH OBJECT oBrw
      :bRClicked := {|r,c,f,o| MenuOpc(r,c,o) }
      :married:SetCheck( { CASADO, if((oBrw:cAlias)->MF == "M", SOLTERO, SOLTERA) } )  // No selecciona bien el 2do elemento
      :CreateFromCode()
   END

   ACTIVATE DIALOG oDlg CENTERED

return nil
//-----------------------------------------------//
Function MenuOpc(nRow,nCol,oBrw)
local cAlias := oBrw:cAlias
local oMenu

   MENU oMenu POPUP
      MENUITEM "Todos"      ACTION ( (cAlias)->(dbClearFilter()), oBrw:Refresh() )
      MENUITEM "Solteros"   ACTION ( dbSetFilter({||(cAlias)->Married = .F.}, "(cAlias)->Married = .F."), (cAlias)->(dbgotop()) , oBrw:Refresh())
      MENUITEM "Casados"    ACTION ( dbSetFilter({||(cAlias)->Married = .T.}, "(cAlias)->Married = .T."), (cAlias)->(dbgotop()) , oBrw:Refresh())
      MENUITEM "Masculino"  ACTION ( dbSetFilter({||(cAlias)->MF = "M"}, "(cAlias)->MF = 'M'" ), (cAlias)->(dbgotop()) , oBrw:Refresh())
      MENUITEM "Femenino"   ACTION ( dbSetFilter({||(cAlias)->MF = "F"}, "(cAlias)->MF = 'F'" ), (cAlias)->(dbgotop()) , oBrw:Refresh())
   ENDMENU

   ACTIVATE POPUP oMenu AT nRow, nCol OF oBrw

Return nil
 

Saludos.
Francisco J. Alegría P.
Chinandega, Nicaragua.

Fwxh-MySql-TMySql
User avatar
FranciscoA
 
Posts: 2159
Joined: Fri Jul 18, 2008 1:24 am
Location: Chinandega, Nicaragua, C.A.


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 64 guests