i need to combobox with the same content in the same form ....
what's the best way to do this ???
Printable View
i need to combobox with the same content in the same form ....
what's the best way to do this ???
Code:For I = 0 To Combo1.ListCount - 1
Combo2.AddItem Combo1.List(I)
Next I
How about this?
Code:Private Sub ReplicateCombo(src As ComboBox, dest As ComboBox)
dest.Clear
For i = 0 To src.ListCount - 1
dest.AddItem src.List(i)
dest.ItemData(i) = src.ItemData(i)
Next i
End Sub
Private Sub Command1_Click()
ReplicateCombo Combo1, Combo2
End Sub
Private Sub Form_Load()
Dim i%
For i = 1 To 10
Combo1.AddItem Str(i)
Next
For i = 0 To Combo1.ListCount - 1
Combo2.AddItem Combo1.List(i)
Next
End Sub
Code:Private Sub Form_Load()
'will fill as many combos as there are on a form with the same content
'mycontrol = control and increment is increment for forms
'
Dim ctlMyControl As Control
Dim intIncrement As Integer
Dim intCre As Integer
'
For intIncrement = 0 To Forms.Count - 1
For Each ctlMyControl In Forms(intIncrement).Controls
If TypeOf ctlMyControl Is ComboBox Then
For intCre = 1 To 10
With ctlMyControl
.AddItem intCre * Int(Rnd * 199)
End With
Next intCre
End If
Next ctlMyControl
'
Next intIncrement
End Sub