Multi Column Array Combo box

Multi Column Array Combo box

Postby TimStone » Wed Oct 04, 2006 10:27 pm

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
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: 2905
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Postby James Bott » Wed Oct 04, 2006 11:49 pm

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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

DBCombo

Postby TimStone » Thu Oct 05, 2006 6:07 pm

Of course, I'm using tData ... and replacing a field in an existing database with a lookup value ....

Tim
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: 2905
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Postby James Bott » Thu Oct 05, 2006 6:33 pm

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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

DBCombo

Postby TimStone » Thu Oct 05, 2006 11:31 pm

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
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: 2905
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Postby James Bott » Fri Oct 06, 2006 3:13 pm

Tim,

I wrote a lot of the DBCombo code so if you want to send me a small example of code and the Pelles RC file, I will see if I can find anything. When you say it didn't display correctly, could you be a little more specific?

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Combo box

Postby TimStone » Fri Oct 06, 2006 5:24 pm

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
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: 2905
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Postby James Bott » Fri Oct 06, 2006 7:32 pm

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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

DBCombo

Postby TimStone » Mon Oct 09, 2006 11:48 pm

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
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: 2905
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 41 guests