cmdolcet69 said:
How can I create a dropdown box at runtime?
In exactly the same way that the Forms Designer does!
No; Seriously. ;-)
Have a look in the "Designer Generated Code" region or the *.designer.vb
file (depending on your version of Visual Basic). These contain the
code that your program runs that creates every control in your program.
Read and Learn ...
(then simplify; /some/ of the code it generates is just /rubbish/).
I want my dropdown box to appear when my user enters the program and
then it would load the save data from an xml file.
Dim cb as New ComboBox()
With cb
.Location = New Point( 0, 0 )
.Size = New Size( 80, 20 ) ' say
.Visible = True
.Items.Add( "X" )
End With
AddHandler cb.SelectedIndexChanged _
, AddressOf AnyComboBox_SelectedIndexChanged
Me[.container].Controls.add( cb )
(Remember that each Control (and Form) acts as a container for other
Controls placed "on" it).
For the Xml stuff:
Dim doc as New Xml.XmlDocument
doc.Load( "file" )
With cb
For Each eNode as XmlNode _
In doc.SelectNodes( "xPath" )
cb.Items.Add( eNode.GetAttribute( Value ) ) ' say
If eNode.GetAttribute( "current" ) <> "" Then
cb.SelectedIndex = cb.Count - 1
End If
Next
End With
HTH,
Phill W.