Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Control not being created

Ralph Kelli MaurmeierRalph Kelli Maurmeier Member Posts: 1

I am trying to create a user control at run time and add it to a list of user controls. However, I keep receiving the same item block and it only moves position in the list. For example, adding a block will add a spot to the user control list, but the user control is still the same control as the first time.

Private Sub addItemGroup()
    Dim item_block As New ucItemsetItemBlock
    item_block.SetIsRemovable(frm.pnlGroups.Controls.Count > 0)
    item_block.Dock = DockStyle.Top
    item_block.Name = "Item group" + (1 + item_set.blocks.Count()).ToString
    AddHandler item_block.flpMain.Click, AddressOf addItemToItemBlock
    item_block.flpMain.Name = (100000 + item_set.blocks.Count()).ToString
    item_block.BringToFront()
    item_block.Visible = True
    item_set.blocks.Add(item_block)
    frm.pnlGroups.Controls.Add(item_block)
    addItemGroupsToForm()
    Console.WriteLine(item_set.blocks.Count.ToString())
End Sub

Private Sub addItemGroupsToForm()
    frm.pnlGroups.Controls.Clear()
    For Each block In item_set.blocks
        frm.pnlGroups.Controls.Add(block)
    Next
    Console.WriteLine(item_set.blocks.Count.ToString())
End Sub
Tagged:
Sign In or Register to comment.