Página 1 de 1

Simple ComboBox question

Publicado: Mié Mar 21, 2007 3:45 pm
por Gejza Horvath
Please help me with TDBComboBox! The situation:
The TDBCombobox named oCombo1 is placed on the form. I have a DBF table (oDbfDataSet1)
with simple structure:
Recno CISLO UCET
1. 01 122330002
2. 02 535535535
3. 03 837737737
I would like to
- display the items from field UCET in dropped combobox
- get the value from field CISLO for the selected UCET
- display the related UCET if I set the existing value from CISLO to oCombo1:Value
My existing and not working solution:
1. Fill the combobox with values from DBF in OnCreate() event of the combobox
oSender:aItems := ::oDbfDataSet1:SaveToArray({ "Ucet"} )
oSender:aItemsBound := ::oDbfDataSet1:SaveToArray({ "Cislo"} )
It's right, debugger shows the {"01","02","03"} in aItemsBound array from CISLO and the
corresponding {"122330002","535535535","837737737"} array from the field UCET in the
aItems array.
2. Setting the initial value from INI file
::oCombo1:Value := oIniPok:GetEntry("LIS","Cislo hlavneho uctu") // the value is "02")
3. oCombo1:nDataType := dtBOUND
oCombo1:nStyle := csDROPDOWN
oCombo1:lEnabled := .T.
And the problem: when the form is displayed, the oCombo1 shows "02" and clicking on the
control it don't drops down.
What is wrong, or generally: how to manage 2 arrays in combobox?
Gejza Horvath

Simple ComboBox question

Publicado: Mié Mar 21, 2007 4:32 pm
por ignacio
Gejza,
1) You can not set any initial value to a Datacontrol, the value is
automatically assigned
2) You must perform a oDataset:Edit() in orde to access any DataControl.
Regards,
--
Ignacio Ortiz de Zúñiga
http://www.xailer.com
"Gejza Horvath" <_hsoftkn@nextra.sk> escribió en el mensaje
news:[email=460144e9@news.xailer.com...]460144e9@news.xailer.com...[/email]
> Please help me with TDBComboBox! The situation:
>
> The TDBCombobox named oCombo1 is placed on the form. I have a DBF table
> (oDbfDataSet1) with simple structure:
>
> Recno CISLO UCET
> 1. 01 122330002
> 2. 02 535535535
> 3. 03 837737737
>
> I would like to
> - display the items from field UCET in dropped combobox
> - get the value from field CISLO for the selected UCET
> - display the related UCET if I set the existing value from CISLO to
> oCombo1:Value
>
> My existing and not working solution:
> 1. Fill the combobox with values from DBF in OnCreate() event of the
> combobox
>
> oSender:aItems := ::oDbfDataSet1:SaveToArray({ "Ucet"} )
> oSender:aItemsBound := ::oDbfDataSet1:SaveToArray({ "Cislo"} )
>
> It's right, debugger shows the {"01","02","03"} in aItemsBound array from
> CISLO and the corresponding {"122330002","535535535","837737737"} array
> from the field UCET in the aItems array.
>
> 2. Setting the initial value from INI file
> ::oCombo1:Value := oIniPok:GetEntry("LIS","Cislo hlavneho uctu") // the
> value is "02")
>
> 3. oCombo1:nDataType := dtBOUND
> oCombo1:nStyle := csDROPDOWN
> oCombo1:lEnabled := .T.
>
> And the problem: when the form is displayed, the oCombo1 shows "02" and
> clicking on the control it don't drops down.
>
> What is wrong, or generally: how to manage 2 arrays in combobox?
>
> Gejza Horvath
>