Skip to Content
0
Former Member
May 07, 2012 at 02:23 PM

Combobox .Selected returning null even when I select a value

238 Views

Hey guys!

I'm having a strange problem in my code. I have a custom form that I created using Screen Painter, and in it there are two comboboxes with the exact same values (Payment Methods).

The problem is: when I try to get the selected value of any of the two comboboxes using ".Selected" it only returns the value if the first item is selected, if I select any other value the .Selected returns null. Does anyone know what could be causing this?

Here is the code I use to fill both comboboxes:

DBDataSource dsDB = oForm.DataSources.DBDataSources.Add("OPYM");

dsDB.Query();

ComboBox formaPgtoCorrente = oForm.Items.Item("cmbCorrPag").Specific;

ComboBox formaPgtoNova = oForm.Items.Item("cmbNovoPag").Specific;

for (int i = 0; i < dsDB.Size; i++)

{

try

{

string value = dsDB.GetValue("PayMethCod", i);

string description = dsDB.GetValue("Descript", i);

formaPgtoCorrente.ValidValues.Add(value, description);

formaPgtoNova.ValidValues.Add(value, description);

}

catch (Exception) { }

}