Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating txt boxes on the fly from combo box index 1

Status
Not open for further replies.

croag

MIS
Nov 8, 2001
49
US
Hello all,

I have a problem that I can't seem to solve by myself. Here's the situation. I have a combo box named cbopump that has a preloaded collection of number in it ( 1-64 ) Below that there is a panel that I would I would like to have txtboxes created on the fly inside of in an 8 x 8 fashion based on the number that is currently selected in the combo box. I've been messing with arrays but I can't seem to get it too work. the number of txtboxes needs to be able to grow and shrink as the number in the combobox changes. PLEASE Help...I've been trying this already for like 6 hours! lol..Thanks in advance!

//croag
 
if you need to display dynamic number of text boxes perhaps you should consider a data grid to display your text.


if it is to be it's up to me
 
Interesting!...Thanks for the suggestion, I'm going to try that in about 20 minutes. I was under the impression a datagrid had to be bound to a datasourcevia a dsn? Hopefully not, I'll give it a try.
 
To do text boxes on the fly in case the datagrid doesn't work out for you, declare a public variable:

Code:
    Dim ptxtBatch(1) As TextBox
    Dim pintRowCounter as Integer
Then add:

Code:
    Private Sub InitializeNewTxtBatch(ByVal RowIndex As Integer)

        With ptxtBatch(RowIndex)
            .Cursor = System.Windows.Forms.Cursors.IBeam
            .Font = New System.Drawing.Font("Tahoma", 9)
            .AcceptsTab = True
            .Top = cTop + (29 * (RowIndex - 1))
            .Left = cLeft + 40
            .Width = 80
            .Height = 29
            .Tag = RowIndex
        End With
        Me.Controls.Add(ptxtBatch(RowIndex))
        Addhandler ptxtbatch(rowindex).TextChanged, Addressof txtBatchTextChange

end Sub
each time you want to create a new text box:
Code:
        pintRowCounter +=1
        ReDim Preserve ptxtBatch(pintRowCounter)
        ptxtBatch(pintRowCounter) = New TextBox()
        Call InitializeNewTxtBatch(RowIndex:=pintRowCounter)

You many have to play with the formulas for left & top.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top