Page 1 of 2

Items en un ComboBox

Posted: Mon Jun 25, 2012 4:22 pm
by arroya2
Hola amigos.

Necesito modificar la lista de opciones de un ComboBox, en tiempo de ejecución, dependiendo de los valores seleccionados en otros ComboBoxes anteriores al que me refiero.
He visto en la guía que, la propiedad Items, solo está disponible en la definición del ComboBox.

¿Cómo lo puedo hacer?

Gracias

Saludos
Rafael Pérez

Re: Items en un ComboBox

Posted: Mon Jun 25, 2012 6:10 pm
by esgici
Hola Rafael
arroya2 wrote:Hola amigos.

Necesito modificar la lista de opciones de un ComboBox, en tiempo de ejecución, dependiendo de los valores seleccionados en otros ComboBoxes anteriores al que me refiero.
He visto en la guía que, la propiedad Items, solo está disponible en la definición del ComboBox.

¿Cómo lo puedo hacer?

Gracias

Saludos
Rafael Pérez
Google Translate wrote:I need to modify the options list of a ComboBox, at runtime, depending on the values ​​selected in other pre ComboBoxes I mean.
I've seen in the guide, the Items property, only available in defining the ComboBox.

How I can do?
I'm not sure that is this you are searching.

I hope help you.

Saludos

--

Esgici

Re: Items en un ComboBox

Posted: Mon Jun 25, 2012 7:05 pm
by IMATECH
You can change items at RunTime... no problem...

See a sample in:
\HMG\SAMPLES\MAIN.DEMO

Code: Select all


    Form_x.List_1.DeleteAllItems 
    Form_x.Combo_1.DeleteAllItems

    Form_x.List_1.AddItem ( "New List Item"  )
    Form_x.Combo_1.AddItem (  "New Combo Item" )


Re: Items en un ComboBox

Posted: Mon Jun 25, 2012 7:19 pm
by arroya2
No es lo que necesito, pero me ha enseñado como hacerlo.
Me han sorprendido las funciones DeleteAllItems() y AddItem(). ¿Son Nuevas? ¿Dónde están documentadas?
Esgici eres fabuloso por lo que sabes, por lo generoso que eres compartiendo tus conocimientos y por tu rapidez en la respuesta.

Te estoy muy agradecido.
Rafael Pérez

Translated by Google:
Not what I need, but has taught me how.
I am surprised DeleteAllItems functions () and AddItem (). Are they new? Where are they documented?
Esgici're fabulous so you know, so generous that you are sharing your knowledge and your prompt response.

I'm very grateful.
Rafael Pérez

Re: Items en un ComboBox

Posted: Mon Jun 25, 2012 7:26 pm
by arroya2
Chacal.GO wrote:You can change items at RunTime... no problem...

See a sample in:
\HMG\SAMPLES\MAIN.DEMO

Code: Select all


    Form_x.List_1.DeleteAllItems 
    Form_x.Combo_1.DeleteAllItems

    Form_x.List_1.AddItem ( "New List Item"  )
    Form_x.Combo_1.AddItem (  "New Combo Item" )

Chacal.GO También te estoy muy agradecido.

Muchas Gracias
Rafael Pérez

Translated by Google:
Chacal.GO also I'm very grateful.

Thank you very much.
Rafael Pérez

Re: Items en un ComboBox

Posted: Mon Jun 25, 2012 7:58 pm
by IMATECH
Thanks Arroya2



You can see this methods in HMG Doc's at:

\HMG\DOC\hmgdoc.htm



Regards

Re: Items en un ComboBox

Posted: Mon Jun 25, 2012 8:26 pm
by arroya2
Chacal.GO wrote:Thanks Arroya2



You can see this methods in HMG Doc's at:

\HMG\DOC\hmgdoc.htm



Regards
Muchas gracias de nuevo.
Rafael Pérez


Translated by Google:
Thank you very much again.
Rafael Pérez

Re: Items en un ComboBox

Posted: Mon Jun 25, 2012 8:47 pm
by esgici
Hola Rafael

I'm glad that you had liked it :)
arroya2 wrote: Not what I need, ...
If you explain your need more clear, I'll try being more helpful for you :arrow:

Saludos

--

Esgici

Re: Items en un ComboBox

Posted: Tue Jul 03, 2012 10:10 am
by arroya2
Translated by Google:
Hello again Esgici.
If you explain your need more clear, I'll try being more helpful for you
What I need is the following:
I have two COMBOBOX, the first I have the list of fields in a DBF and the second list is empty.
The first is active and the second is disabled until you press ENTER on the first. Just then I fill the list and activate the second COMBOBOX.
The list of the second COMBOBOX depends on what you select in the first COMBOBOX.

I hope I explained correctly.

Regards
Rafael Pérez
Hola de nuevo Esgici.
If you explain your need more clear, I'll try being more helpful for you
Lo que necesito es lo siguiente:
Dispongo de dos COMBOBOX, en el primero tengo la lista de los campos de una DBF y en el segundo la lista está vacía.
El primero está activo y el segundo está desactivado hasta el momento que pulse ENTER en el primero. Justo en ese instante quiero llenar la lista del segundo COMBOBOX y activarlo.
La lista del segundo COMBOBOX depende de lo que seleccione en el primer COMBOBOX.

Espero haberme explicado correctamente.

Saludos
Rafael Pérez

Re: Items en un ComboBox

Posted: Tue Jul 03, 2012 1:20 pm
by Rossine
Hi Rafael,

See if this is what you need ;)

Code: Select all

#include "hmg.ch"
#include "hbcompat.ch"

function MAIN

  DEFINE WINDOW Form_1 ;
    AT 0,0 ;
    WIDTH 400 ;
    HEIGHT 200 ;
    TITLE 'ComboBox Demo' ;
    MAIN NOSIZE

    ON KEY ESCAPE action Form_1.release

    DEFINE COMBOBOX Combo_1
      ROW 40
      COL 10
      WIDTH 100
      ITEMS { 'Field 1', 'Field 2', 'Field 3', 'Field 4', 'Field 5', 'Field 6' }
      VALUE 1
      ON ENTER SET_COMB2()
    END COMBOBOX

    DEFINE COMBOBOX Combo_2
      ROW 40
      COL 200
      WIDTH 100
      ITEMS { }
      VALUE 1
      ON ENTER Form_1.Combo_1.setfocus
      ON LOSTFOCUS Form_1.Combo_2.enabled := .F.

    END COMBOBOX

  END WINDOW

  Form_1.Combo_2.enabled := .F.

  CENTER WINDOW Form_1

  ACTIVATE WINDOW Form_1

Return Nil

*************************
static function SET_COMB2
*************************

local i, aItems, cItem := _GetItem( "Combo_1", "Form_1", Form_1.Combo_1.value )

i := GetControlIndex( "Combo_2", "Form_1" )

aItems := _HMG_aControlMiscData1 [i,4]

if ascan( aItems, cItem ) = 0
   aadd( aItems, cItem )
   SetComboItens( "Form_1", "Combo_2", aItems, len(aItems) )
   Form_1.Combo_2.enabled := .T.
   Form_1.Combo_2.setfocus
else
   msgstop( "Ops, this item is found is combo 2 :)", "" )
endif

Return Nil

**********************
function SetComboItens( cWnd, cCbx, aItens, nAt, aImage )
**********************

local i, n

hb_default( @nAt   , 1 )
hb_default( @aImage, { } )

try
  i := GetControlIndex( cCbx, cWnd )
catch
  i := 0
end

if i > 0
   domethod( cWnd, cCbx, "DeleteAllItems" )
   for n = 1 to len(aItens)
       if !empty( aImage ) .and. len(aImage) >= n
          _AddItem( cCbx, cWnd, , , aImage[n] )
       else
          domethod( cWnd, cCbx, "AddItem", aItens[n] )
       endif
   next
   setproperty( cWnd, cCbx, "value", nAt )
else
   msgstop( "Combobox not exist [" + cWnd + "." + cCbx + "]. check !!!", "Error" )
endif

return aItens

Best Regards,

Rossine.