Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using bound controls on the fly 1

Status
Not open for further replies.

artyk

Programmer
Apr 5, 2006
163
US
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.

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!
 
That solution is absolutely perfect! Thank you very much! I never considered initiating the loop from the last control, it makes perfect sense now, though. Thanks again!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top