COMBOBOX with 2 element array

COMBOBOX with 2 element array

Postby TimStone » Fri Nov 11, 2022 1:31 am

I thought this was addressed earlier with a simple solution. I can write code to "make it happen" but if it is already addressed with FWH, I would like to use it:

Field 1 is a title
Field 2 is a description.
Both are in a database
I want to read them into a 2 element array.
Then, using a combobox ( or listbox ), I want the first element ( field 1 ) to be the items
When an item is selected ( ON CHANGE ), I want the value in the second element to be assigned to a variable used in a separate GET ( for editing ).

I thought this was addressed in the forum, and code, previously, but I can't find it.

Currently I assign the values to 2 arrays, use the first to select the title, and knowing it's position, I load the corresponding value from the second array into the variable. That has been my procedure in the past but I "think" a more direct approach was shared previously.

Any thoughts will be helpful. Thanks.
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: COMBOBOX with 2 element array

Postby Antonio Linares » Fri Nov 11, 2022 7:02 am

regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: COMBOBOX with 2 element array

Postby nageswaragunupudi » Fri Nov 11, 2022 10:24 am

Mr. Tim
That is what DBCOMBO is supposed to do
Please look for samples of DBCOMBO
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10643
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: COMBOBOX with 2 element array

Postby TimStone » Sat Nov 12, 2022 1:50 am

I looked at the other posts, and also studied dbcombo. Those were really more complex then I need.

Code: Select all  Expand view
   REDEFINE COMBOBOX oCbxA1 VAR cScript  ID 106 OF oeText ;
      ITEMS aSMScode  ON CHANGE ( lx := oCbxA1:nAt, cBody := aSMStext[lx], oGet1:refresh() )   ;
      MESSAGE "Select a script" STYLE CBS_DROPDOWN UPDATE
   
    REDEFINE GET oGet1 VAR cBody MEMO  ID 103 OF oeText MESSAGE "Enter the text of your message" UPDATE
 


I took the DBF, and put the first field in the array aSMScode, and the second field in aSMStext.
This code takes the selected item in the dropdown, and looks at the corresponding element in the second array. It takes that 2nd array value and puts it into cBody which is the text to be used, or edited.

This works exactly as I wanted. It's not complex. I just thought we could perhaps use an array of 2 element arrays. That doesn't appear to be how dbcombo works either.

Thanks.
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA


Return to FiveWin for Harbour/xHarbour

Who is online

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