Changing itemlist in a combobox

Changing itemlist in a combobox

Postby driessen » Sun Dec 04, 2022 11:58 am

Hello,

I think I asked this question some years ago, but I can't it find it anymore, nore do I remember the solution that was given then.

This is my question:

In a window, I use a combobox. The list that is defined, need to be changed, depending on changing the data in the window.

How can I change a itemlist of an active combobox in my window?

Thank you very much in advance for any help.
Regards,

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
User avatar
driessen
 
Posts: 1422
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Re: Changing itemlist in a combobox

Postby Marc Venken » Sun Dec 04, 2022 12:18 pm

Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1434
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: Changing itemlist in a combobox

Postby cmsoft » Sun Dec 04, 2022 12:36 pm

Driessen:
Algo asi?
Code: Select all  Expand view

#include "fivewin.ch"
function Prue_Combo()
   local oDlg, oCom1, oCom2, cVar1, cVar2
   local aList1, aList2

   aList1 := {"Opcion1","Opcion2"}

   aList2 := {"Opcion 1 - Item 1", "Opcion 1 - Item2", "Opcion 1 - Iteme3"}
   
   cVar1 := aList1[1]

   cVar2 := aList2[1]



   DEFINE DIALOG oDlg FROM 1,1 TO 300, 600 PIXEL TITLE "Combobox Relacionados"

   @ 20, 10 COMBOBOX oCom1 VAR cVar1 ITEMS aList1 SIZE 130,200 PIXEL OF oDlg ;
            ON CHANGE ( aList2:=MiFunction(oCom1),oCom2:SetItems(aList2 ), oCom2:Set(aList2[1]))

   @ 20,160 COMBOBOX oCom2 VAR cVar2 ITEMS aList2 SIZE 130,200 PIXEL OF oDlg
   
   @ 100,(300/2)-(100/2) BUTTON "Ok" SIZE 100, 20 PIXEL OF oDlg ;
            ACTION oDlg:End()

 
   ACTIVATE DIALOG oDlg CENTERED

return nil

Function MiFunction(oCom1)
local aResp
IF oCom1:nAt = 1
   aResp :=  {"Opcion 1 - Item 1", "Opcion 1 - Item 2", "Opcion 1 - Iteme 3"}
   ELSE
   aResp := {"Opcion 2 - Item 1", "Opcion 2 - Item 2", "Opcion 2 - Item 3","Opcion 2 - Item 4"}
ENDIF
Return aResp
 
User avatar
cmsoft
 
Posts: 1290
Joined: Wed Nov 16, 2005 9:14 pm
Location: Mercedes - Bs As. Argentina


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 89 guests