Control Question!!! Help!!!

  • 14 years ago

    Ok guys i need your help.

    I have a panel control with a textbox inside, next to the panel there is a button. Now what i want, and i don't know how to do it, is when i click at the  button i want that another panel show under the first panel, but exactly like the first panel with a textbox inside and a button next to it.



    Merovingio.Wink [;)]

  • 14 years ago

    Please help me, i really need this.

    What i mean was that i want that the second panel be down the first. 

  • 14 years ago

    Could you clarify your problem a little for me.  Would this be an accurate description of what you want to occur.

    You have a Panel and next to it a button.  You click the button.  A Panel and a NEW button appear below this.  At this point you have Two Buttons and Two Panels.  Can both buttons be clicked?  When either is clicked does a third Panel/Button combo appear?  Should it be below all other panels/buttons.  OR does a new panel get created but the first Button gets moved? 

  • 14 years ago

    mmm it's like this:

    I've seen this in a web page where you insert a record and then click at the "new" link and down of the record that you insert shows another row to insert a new record. 

    mmm, i don't know if you have seen this; about the button, it disappears when you click it but appears down with the new record.



  • 14 years ago

    I hope this code helps you.  Just paste this code into the project code editor and run the program.  The comments should help explain what I've done.  I think it accomplishes what you'd like, but you'll definitly want to modify it to your liking (ie. controls sizes and all that stuff).  Hopefully you can work with it though.

    Public Class Form1
        'Location of the next Panel
        Dim NextRecLoc As New Point(10, 10)
        'The "active" textbox (TextBox left of the button)
        Dim CurrentTextBox As TextBox = Nothing
        Dim WithEvents btnPanelButton As New Button

    'Adds a panel with textbox below the last one
    Private Sub NextRecord()
        'Distance between panels
        Dim SPACER As Integer = 10
        'New panel object
        Dim newPanel As New Panel
        'Set a border style so we can see the panel
        newPanel.BorderStyle = BorderStyle.FixedSingle
        'Set the panels size
        newPanel.Size = New Size(300, 40)
        'Set the location
        newPanel.Location = NextRecLoc + Me.AutoScrollPosition
        'New TextBox object for the panel
        Dim newTextBox As New TextBox
        newTextBox.Size = New Size(200, 20)
        newTextBox.Location = New Point(10, 5)
        'Set the current textbox to this new one
        CurrentTextBox = newTextBox
        'Add the new TextBox to the panel
        'Adjust NextRecLoc
        NextRecLoc.Y += newPanel.Size.Height + SPACER
        'Add the panel to the form
        'Move the button to the right of newPanel
        btnPanelButton.Location = New Point(newPanel.Right + 10, newPanel.Top)
    End Sub
    Private Sub btnPanelButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPanelButton.Click
        'Do what you want with the information in the "active" textbox here
        If CurrentTextBox IsNot Nothing Then
            'Display the text
        End If
        'Create a new record
    End Sub
    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        'Turns on the forms AutoScroll
        Me.AutoScroll = True
        'Add the button to the form
        btnPanelButton.Size = New Size(75, 25)
        btnPanelButton.Text = "Submit"
        'Create the first record
    End Sub
    End Class
  • 14 years ago

    Thanks TwoFaced, it's just what i was looking for.Cool [H]



Post a reply

Enter your message below

Sign in or Join us (it's free).


Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.” - Rick Osborne