如何访问运行时创建的组合框

时间:2016-02-25 14:48:17

标签: vb.net combobox

1)如何访问以下代码创建的组合,并在点击combo5.Backcolor = vbgreen后设置button1

2)点击combo5.Backcolor

后如何将vbgreen设置为combo5

3)如何在创建特定组合后将项添加到组合(即combo.Items.Add

Private Sub CreateComboArray(ByVal number As Integer, ByVal container As Control)

    Dim previouscombowidth As Integer = 0
    Dim position As Integer = 7
    Dim combo As ComboBox
    For i As Integer = 0 To number - 1

        combo = New ComboBox()
        combo.Name = "combo" + i.ToString()
        combo.Items.Add(RichTextBox1.Text.Split(" ")(i))
        combo.SelectedIndex = 0
        container.Controls.Add(combo)

        combo.Height = 22
        combo.Width = (5 * combo.SelectedItem.ToString.Length) + 10

        If i > 0 Then 
            position += previouscombowidth + 3 
        End If

        combo.Left = position
        combo.DropDownStyle = ComboBoxStyle.Simple
        previouscombowidth = combo.Width 
    Next


End Sub

0 个答案:

没有答案