FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour COMBOBOX with 2 element array
Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
COMBOBOX with 2 element array
Posted: Fri Nov 11, 2022 01: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
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: COMBOBOX with 2 element array
Posted: Fri Nov 11, 2022 07:02 AM
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: COMBOBOX with 2 element array
Posted: 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
Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Re: COMBOBOX with 2 element array
Posted: Sat Nov 12, 2022 01:50 AM
I looked at the other posts, and also studied dbcombo. Those were really more complex then I need.
Code (fw): Select all Collapse
    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

Continue the discussion