Didplay of controls in Groupbox

Giganews Newsgroups
Subject: Didplay of controls in Groupbox
Posted by:  Michel (Mich…@discussions.microsoft.com)
Date: Thu, 11 Jun 2009

Hello,

I want to display a series of controls (Comboboxes) in a Groupbox.
Therefor, I use following code:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim iTop As Integer = 30
Dim cboZoekCriterium As New ComboBox

For iTeller = 1 To 6
  With cboZoekCriterium
      .Location = New Point(10, iTop)
      .Name = "cboZoekCriterium_" & String.Format("{0:0000}", iTeller)
      .Size = New Size(250, 20)
  End With

  GroupBox1.Height = iTop + 40
  Me.GroupBox1.Controls.Add(cboZoekCriterium)

  iTop = iTop + 40
Next iTeller

End Sub

Can anyone explain me why only the last Combobox is displayed in the
Groupbox? If I change the number of 6 to any other number, again only the
last Combobox is displayed.

Many thanks and greetings,

Michel

Replies