FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Workaround to make DBCOMBO to work with numeric Item field
Posts: 115
Joined: Mon Oct 17, 2005 04:42 AM
Workaround to make DBCOMBO to work with numeric Item field
Posted: Wed Feb 22, 2006 06:57 AM

Hello,

Is there any workaround to make DBCOMBO to work with numeric Item field ? We are in the process of converting legacy application into FWH. And almost all the applications has numeric primary key in the master table. I am heavily stuck up here.

Can anybody guide me ?

TIA
Milan.

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Workaround to make DBCOMBO to work with numeric Item fie
Posted: Wed Feb 22, 2006 07:41 AM

Can't you just use Str( FieldName )?

EMG

Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Workaround to make DBCOMBO to work with numeric Item field
Posted: Wed Feb 22, 2006 07:45 AM

Milan,

You can preload the data into arrays (and convert the data to string while doing that). Then use the SET method:

METHOD SetItems( aItems, aList )

When you save the selected item no. you may need to convert it back to numeric.

The problem is that the data needs to be string for the combobox class which is the base class of dbcombo.

Another way would be to modify the dbcombo source. The downside is that you will either not automatically get any improvements to newer versions of DBCombo that come with FW.

Maybe the best thing would be to customize a copy of dbcombo and give it a new class name. That is probably what I would do, but if you are not familiar with writing classes this may take some effort for you.

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 115
Joined: Mon Oct 17, 2005 04:42 AM
Workaround to make DBCOMBO to work with numeric Item field
Posted: Thu Feb 23, 2006 11:00 AM
Dear James,

Do u mean to say that I should try to array browse with DBCOMBO ? Even that do not seem to work as the value return by DBCOMBO is still numeric (i.e. still from Database). I had filled both aItems and aList with proper values (string one).

Can u please guide further ?

TIA
Milan.


James Bott wrote:Milan,

You can preload the data into arrays (and convert the data to string while doing that). Then use the SET method:

METHOD SetItems( aItems, aList )

When you save the selected item no. you may need to convert it back to numeric.

The problem is that the data needs to be string for the combobox class which is the base class of dbcombo.

Another way would be to modify the dbcombo source. The downside is that you will either not automatically get any improvements to newer versions of DBCombo that come with FW.

Maybe the best thing would be to customize a copy of dbcombo and give it a new class name. That is probably what I would do, but if you are not familiar with writing classes this may take some effort for you.

James
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Workaround to make DBCOMBO to work with numeric Item field
Posted: Thu Feb 23, 2006 02:19 PM
Milan,

Even that do not seem to work as the value return by DBCOMBO is still numeric (i.e. still from Database). I had filled both aItems and aList with proper values (string one).


I see there is a bug in DBCombo when you try to pass the arrays in the definition like this:

@ 10,30 dbcombo oDBC var cItem of oDlg;
items aItems;
list aList

Instead do it like this:

@ 10,30 dbcombo oDBC var cItem of oDlg
oDBC:setItems( aItems, aList )

This is working for me.

James
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10

Continue the discussion