comboBox irregular behavior???

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

I'm using MS Visual C#.NET

Microsoft Development Environment 2002 Version 7.0.9955 (spanish edition)
Microsoft .NET Framework 1.0 Versión 1.0.3705 (spanish edition)
(Microsoft Visual C# .NET 55609-652-0000007-18500)

I'm working on a simple database project and building a Windows Form App. In
the app there is a comboBox component (named provincias_comboBox) which is
dataBinded to a table in a database.

In the process of finding a particular record, by a given criteria, all the
components corresponding to table fields, shown in the form are updated,
including the provincias_comboBox 's Text property. And it indeed changes in
the form view.

Code:
string tempProvincia;
tempProvincia = (string) dataTable.Rows[ 0 ][ 3 ]; // This
temporary table field contains the value to be assigned

provincia_comboBox.Text = tempProvincia;
MessageBox.Show(tempProvincia + "\n\n" + provincia_comboBox.Text);

But when I try to get the Text property value as in the last code line
above, the property contains the old value. Thus, the resulting dialog
message box show two differet strings: the updated value (the same shown now
in the visual comboBox component) and another: the yet unchanged old value
for the Text property of the provincia_comboBox component
(provincia_comboBox.Text ).

I wonder why this is happening.

I'll appreciate any help.

Eric
 
Why not you populate your combobox with Value as well as Text(not Text
only) so that while displaying text in combo box for a particular
record, you need to search for Value and use SelectedIndex property.

rahool
 
Back
Top