For aWebForm, if you mean by selectbox a ListBox, then here is an example:
For ds a DataSet, states.xml an XML file containing a list of states with
Field1 containing the state abbreviation, you would do the following to
populate the list box DropDownStateList:
ds.Clear()
ds.ReadXml(Server.MapPath(".") & "\states.xml")
Me.DropDownStateList.DataSource = ds
Me.DropDownStateList.DataTextField = "Field1"
Me.DropDownStateList.DataBind()
For aWindowsForm, and a ComboBox, it would be something like
ds.Clear()
ds.ReadXml("..\states.xml")
Me.ComboBoxState.DataSource = ds.Tables(0)
Me.ComboBoxState.DisplayMember = "Field2" 'name
Me.ComboBoxState.ValueMember = "Field1" 'abreviation
"Stefan Richter" <sp**@spammenot.com> wrote in message
news:c7***********@otis.netspace.net.au...
I would like to fill a Selectbox dynamically.
I am taking all values from a db, and fill them into a selectbox.
I guess the best way was to use some kind of a dynamical array, where you
don't have to say how many
elements it will contain.
In Java there exists special containers to achieve that, but what about
VB? I thought about somethign like that:
select year from db
while dynamischesArray.AddNewValue(nextResult)
How to get this done as easy and good as possible?
Thanks,
Stefan