I'm used to using a pop up browse whenever the value of a combo box requires more than 1 column be displayed. I show the value in column 1 and a description in column 2. When I select the element, the value is returned.
Do we have this capability yet in FW within the combobox get field ?
Tim
Multi Column Array Combo box
Multi Column Array Combo box
Tim Stone
http://www.MasterLinkSoftware.com
timstone@masterlinksoftware.com
Using: FWH 19.06 with Harbour 3.2.0 / Microsoft Visual Studio Community 2019
http://www.MasterLinkSoftware.com
timstone@masterlinksoftware.com
Using: FWH 19.06 with Harbour 3.2.0 / Microsoft Visual Studio Community 2019
- James Bott
- Posts: 4654
- Joined: Fri Nov 18, 2005 4:52 pm
- Location: San Diego, California, USA
- Contact:
Tim,
You can do this with a DBCombo. If the data is already in a DBF and you don't really need to display the value, then just display the description and DBCombo returns the value.
REDEFINE DBCOMBO oCbx VAR cDeptCode ID 101 OF oDlg ;
ALIAS 'DEPT' ;
ITEMFIELD 'DEPTCODE' ;
LISTFIELD 'DEPTNAME'
Otherwise, if you really must display the value, then create two arrays, one containing both the value and the description concantenated, and another containing just the value. Use the concantenated array as the description (aList) array and the value array as the other (aItem). The value will then be returned.
oCbx:setItems( aItem, aList )
I find that most users don't care a bit about the value (custno, etc.). It is the computer that needs that, so I usually just display the value.
James
You can do this with a DBCombo. If the data is already in a DBF and you don't really need to display the value, then just display the description and DBCombo returns the value.
REDEFINE DBCOMBO oCbx VAR cDeptCode ID 101 OF oDlg ;
ALIAS 'DEPT' ;
ITEMFIELD 'DEPTCODE' ;
LISTFIELD 'DEPTNAME'
Otherwise, if you really must display the value, then create two arrays, one containing both the value and the description concantenated, and another containing just the value. Use the concantenated array as the description (aList) array and the value array as the other (aItem). The value will then be returned.
oCbx:setItems( aItem, aList )
I find that most users don't care a bit about the value (custno, etc.). It is the computer that needs that, so I usually just display the value.
James
DBCombo
Of course, I'm using tData ... and replacing a field in an existing database with a lookup value ....
Tim
Tim
Tim Stone
http://www.MasterLinkSoftware.com
timstone@masterlinksoftware.com
Using: FWH 19.06 with Harbour 3.2.0 / Microsoft Visual Studio Community 2019
http://www.MasterLinkSoftware.com
timstone@masterlinksoftware.com
Using: FWH 19.06 with Harbour 3.2.0 / Microsoft Visual Studio Community 2019
- James Bott
- Posts: 4654
- Joined: Fri Nov 18, 2005 4:52 pm
- Location: San Diego, California, USA
- Contact:
Tim,
>Of course, I'm using tData ... and replacing a field in an existing database with a lookup value ....
Great, then something like this will work:
REDEFINE DBCOMBO oCbx VAR oDept:deptCode ID 101 OF oDlg ;
ALIAS oDept:cAlias ;
ITEMFIELD 'DEPTCODE' ;
LISTFIELD 'DEPTNAME';
UPDATE
This will display the field DEPTNAME and post the oDept:deptCode var back into the DEPTCODE field.
If you want to display both fields, then you will have to use arrays as I mentioned in my previous message.
I forgot to mention that the current version of DBCombo also has built-in incremental searching. The database must be indexed on the displayed field using the UPPER() function. The backspace key is functional, and the spacebar resets the search. You can also use the up and down arrow keys when the incremental search gets close to a match.
James
>Of course, I'm using tData ... and replacing a field in an existing database with a lookup value ....
Great, then something like this will work:
REDEFINE DBCOMBO oCbx VAR oDept:deptCode ID 101 OF oDlg ;
ALIAS oDept:cAlias ;
ITEMFIELD 'DEPTCODE' ;
LISTFIELD 'DEPTNAME';
UPDATE
This will display the field DEPTNAME and post the oDept:deptCode var back into the DEPTCODE field.
If you want to display both fields, then you will have to use arrays as I mentioned in my previous message.
I forgot to mention that the current version of DBCombo also has built-in incremental searching. The database must be indexed on the displayed field using the UPPER() function. The backspace key is functional, and the spacebar resets the search. You can also use the up and down arrow keys when the incremental search gets close to a match.
James
DBCombo
Actually, the problem I had was with the .RC file. I used a standard combo box control but it didn't display correctly with this command.
I use the Pelles C resource program, and compile it in xHarbour, so its a little different than the example Antonio provides.
I'll have to play with it ...
Tim
I use the Pelles C resource program, and compile it in xHarbour, so its a little different than the example Antonio provides.
I'll have to play with it ...
Tim
Tim Stone
http://www.MasterLinkSoftware.com
timstone@masterlinksoftware.com
Using: FWH 19.06 with Harbour 3.2.0 / Microsoft Visual Studio Community 2019
http://www.MasterLinkSoftware.com
timstone@masterlinksoftware.com
Using: FWH 19.06 with Harbour 3.2.0 / Microsoft Visual Studio Community 2019
- James Bott
- Posts: 4654
- Joined: Fri Nov 18, 2005 4:52 pm
- Location: San Diego, California, USA
- Contact:
Combo box
This is a standard combo box control in the .rc script:
CONTROL "", 101, "ComboBox", WS_BORDER|CBS_DROPDOWNLIST|WS_VSCROLL|WS_TABSTOP, 126, 10, 147, 163
The box displayed has no dropdown icon when used with DBCOMBO, but it works fine with the regular FWH COMBOBOX code. If I clickon the box itself, it changes color and has a bold line beneath it, but no list.
Tim
CONTROL "", 101, "ComboBox", WS_BORDER|CBS_DROPDOWNLIST|WS_VSCROLL|WS_TABSTOP, 126, 10, 147, 163
The box displayed has no dropdown icon when used with DBCOMBO, but it works fine with the regular FWH COMBOBOX code. If I clickon the box itself, it changes color and has a bold line beneath it, but no list.
Tim
Tim Stone
http://www.MasterLinkSoftware.com
timstone@masterlinksoftware.com
Using: FWH 19.06 with Harbour 3.2.0 / Microsoft Visual Studio Community 2019
http://www.MasterLinkSoftware.com
timstone@masterlinksoftware.com
Using: FWH 19.06 with Harbour 3.2.0 / Microsoft Visual Studio Community 2019
- James Bott
- Posts: 4654
- Joined: Fri Nov 18, 2005 4:52 pm
- Location: San Diego, California, USA
- Contact:
Tim,
OK, I tried using the same style by editing a Workshop generated RC to create the exact same style attibutes, and the DBCombo still works for me (FWH Aug 2006 build/xHarbour/BCC55 under XP Pro).
Are you using the Pelles C compiler?
What version of FWH are you using?
Are you using Harbour or xHarbour?
What is the date of your dbcombo.prg file? (Mine is 7/6/06)
It still might be helpful if you can create a small stand alone program with the RC file that I can test here.
James
OK, I tried using the same style by editing a Workshop generated RC to create the exact same style attibutes, and the DBCombo still works for me (FWH Aug 2006 build/xHarbour/BCC55 under XP Pro).
Are you using the Pelles C compiler?
What version of FWH are you using?
Are you using Harbour or xHarbour?
What is the date of your dbcombo.prg file? (Mine is 7/6/06)
It still might be helpful if you can create a small stand alone program with the RC file that I can test here.
James
DBCombo
I'm using xHarbour Builder October 2006
I'm using FWH from March 2006
The DBCombo.prg is from 2/26/2006
I'm using Pelles to create the RC but its actually being compiled in xHarbour.
I will try building a small sample to test it.
Tim
I'm using FWH from March 2006
The DBCombo.prg is from 2/26/2006
I'm using Pelles to create the RC but its actually being compiled in xHarbour.
I will try building a small sample to test it.
Tim
Tim Stone
http://www.MasterLinkSoftware.com
timstone@masterlinksoftware.com
Using: FWH 19.06 with Harbour 3.2.0 / Microsoft Visual Studio Community 2019
http://www.MasterLinkSoftware.com
timstone@masterlinksoftware.com
Using: FWH 19.06 with Harbour 3.2.0 / Microsoft Visual Studio Community 2019