News:

Choose a design and let our professionals help you build a successful website   - ITAcumens

Main Menu

add and remove buttons

Started by nandagopal, May 18, 2009, 04:17 PM

Previous topic - Next topic

nandagopal

When the user clicks the Add button, the program uses Load to add a new button to the cmdButton control array. It sets the new button's Container so it is in the same PictureBox as the other buttons. It then calls subroutine SetScrollBar to adjust the buttons' scroll bar.


Private Sub cmdAdd_Click()
Dim new_index As Integer

    new_index = cmdButton.UBound + 1
    Load cmdButton(new_index)
    cmdButton(new_index).Move _
        cmdButton(new_index - 1).Left, _
        cmdButton(new_index - 1).Top + cmdButton(new_index _
            - 1).Height + 120
    cmdButton(new_index).Container = _
        cmdButton(new_index - 1).Container
    cmdButton(new_index).Visible = True
    cmdButton(new_index).Caption = "Button " & _
        Format$(new_index)

    SetScrollBar
End Sub

Private Sub SetScrollBar()
    ' Size the inner PictureBox.
    InnerPict.Height = cmdButton(cmdButton.UBound).Top + _
        cmdButton(cmdButton.UBound).Height + 120

    ' See if we need the scroll bar.
    If InnerPict.Height <= OuterPict.ScaleHeight Then
        InnerPict.Move 0, 0
        VBar.Visible = False
    Else
        ' Set scroll bar properties.
        VBar.Min = 0
        VBar.Max = OuterPict.ScaleHeight - InnerPict.Height
        VBar.LargeChange = OuterPict.ScaleHeight
        VBar.SmallChange = OuterPict.ScaleHeight / 5
        VBar.Visible = True
    End If
End Sub


When the user clicks the Remove button, the program unloads the most recently created button from the control array. It then calls subroutine SetScrollBar to adjust the buttons' scroll bar.


Private Sub cmdRemove_Click()
    If cmdButton.UBound < 1 Then Exit Sub

    Unload cmdButton(cmdButton.UBound)
    SetScrollBar
End Sub



dhoni

with this using easy program the .net should easy to solve
this program will use for add and remove button in .net