textbox RRS feed

  • Question

  • hi i want to enter the textboxes according to the number that means when even i input 5 it should display 5 text boxes dynamically..
    help please

    • Edited by midhun unni Thursday, February 11, 2016 10:30 AM
    Thursday, February 11, 2016 10:29 AM


  • You will need to create new TextBox objects, set their properties as desired and then add them to your form's Controls collection. One property you will certainly need to set is Location, you will need to set the location of each TextBox so that they don't overlap. 

    The following Function can be called to add a specified number of TextBoxes to the form beginning at a specified distance from the top of the form. The Textboxes are added one above the other with a space of 10 points between them.  The Function returns the position where the next TextBox would be added (in case you want to call the Function again).

    Private Function AddTextBoxes(number As Integer, top As Integer) as Integer
        Dim left As Integer = 10, width As Integer = 100, height As Integer = 20
        For i As Integer = 0 To number - 1
            Dim tb As New TextBox With {.Location = New Point(left, top + i * (height + 10)), .Size = New Size(width, height)}
        Return top + number * (height + 10)
    End Function

    Thursday, February 11, 2016 1:05 PM