I am currently working on an application that creates some controls at runtime based on the number of records in the table. I have run into a strange problem however and wanted to see if anyone had any ideas.
The app adds controls just fine and sets the attributes (name, size, position, etc.) just as it is supposed to. But, when it is setting the selected values for the comboboxes on the form, it sets them all to the same value. The combobox names are created on the fly also and are incremented (ex. cboStaffJob & x+1) according to the iteration #.
They are obviously set up using a variable and referenced by the variable when the values are set.
I just can't figure out why they are all being set to the same value. I know it has something to do with the databinding, but I've checked to make sure the names, etc. are being incremented.
I'm obviously doing something wrong, but what?
Thanks in advance!
The app adds controls just fine and sets the attributes (name, size, position, etc.) just as it is supposed to. But, when it is setting the selected values for the comboboxes on the form, it sets them all to the same value. The combobox names are created on the fly also and are incremented (ex. cboStaffJob & x+1) according to the iteration #.
They are obviously set up using a variable and referenced by the variable when the values are set.
Code:
Dim cbo as new combobox
cbo.Name = "cboStaffJob" & x+1
.
.
.
Dim tmpRecordJob as string = rstRecord.Item(1)
.
.
.
cbo.SelectedValue = tmpRecordJob
I just can't figure out why they are all being set to the same value. I know it has something to do with the databinding, but I've checked to make sure the names, etc. are being incremented.
I'm obviously doing something wrong, but what?
Thanks in advance!