Items en un ComboBox
Moderator: Rathinagiri
Items en un ComboBox
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
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
- esgici
- Posts: 4543
- Joined: Wed Jul 30, 2008 9:17 pm
- DBs Used: DBF
- Location: iskenderun / Turkiye
- Contact:
Re: Items en un ComboBox
Hola Rafael
I hope help you.
Saludos
--
Esgici
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
I'm not sure that is this you are searching.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 hope help you.
Saludos
--
Esgici
Viva INTERNATIONAL HMG
Re: Items en un ComboBox
You can change items at RunTime... no problem...
See a sample in:
\HMG\SAMPLES\MAIN.DEMO
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" )
M., Ronaldo
By: IMATECH
Imation Tecnologia
By: IMATECH
Imation Tecnologia
Re: Items en un ComboBox
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
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
Chacal.GO También te estoy muy agradecido.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" )
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
Thanks Arroya2
You can see this methods in HMG Doc's at:
\HMG\DOC\hmgdoc.htm
Regards
You can see this methods in HMG Doc's at:
\HMG\DOC\hmgdoc.htm
Regards
M., Ronaldo
By: IMATECH
Imation Tecnologia
By: IMATECH
Imation Tecnologia
Re: Items en un ComboBox
Muchas gracias de nuevo.Chacal.GO wrote:Thanks Arroya2
You can see this methods in HMG Doc's at:
\HMG\DOC\hmgdoc.htm
Regards
Rafael Pérez
Translated by Google:
Thank you very much again.
Rafael Pérez
- esgici
- Posts: 4543
- Joined: Wed Jul 30, 2008 9:17 pm
- DBs Used: DBF
- Location: iskenderun / Turkiye
- Contact:
Re: Items en un ComboBox
Hola Rafael
I'm glad that you had liked it
Saludos
--
Esgici
I'm glad that you had liked it
If you explain your need more clear, I'll try being more helpful for youarroya2 wrote: Not what I need, ...
Saludos
--
Esgici
Viva INTERNATIONAL HMG
Re: Items en un ComboBox
Hola de nuevo Esgici.Translated by Google:
Hello again Esgici.
What I need is the following:If you explain your need more clear, I'll try being more helpful for you
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
Lo que necesito es lo siguiente:If you explain your need more clear, I'll try being more helpful for you
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
Hi Rafael,
See if this is what you need
Best Regards,
Rossine.
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
Rossine.