adding a set of controls for each row in a record

cwfontan

Active member
Joined
Jan 9, 2009
Messages
35
Programming Experience
1-3
how do I add a few textboxes, comboboxes for each for in datatable?

Imports System.Drawing.Color

Public Class EdiSetup
Inherits System.Windows.Forms.Form


Sub getSegments(ByVal inParentID As Integer)
'Controls
Private txtBox As New TextBox()

childTable = dsElements.Tables("child_elements")
Dim p As Integer = 0
Dim i As Integer = 0

'create textbox for each row in child_elements
For Each childrow In childTable.Rows
Dim childID As Integer = childTable.Rows(p).Item(i)
Panel1.Visible = False

'I am pretty sure I need to give each txtbox a unique name,
'just add the childID variable to end somehow?
With Me.txtBox
.Text = childID
.Location = New System.Drawing.Point(200, 55)
.Size() = New System.Drawing.Size(70, 20)
End With
Next

end sub



Private Sub TreeView1_AfterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterSelect
Label1.Text = "You are here->" & " " & e.Node.FullPath
'displaying the path of the selected node
Label2.Text = "Current node selected:" & " " & e.Node.Text
'displaying the selected node
Dim strRecordID As Integer
strRecordID = e.Node.Tag
getSegments(strRecordID)
End Sub
 
maybe I have it here.. looks like it.. now question is how do I clear them..
I have a treeview and when i click a parent node it popualtes the form with textboxes for each of the child records in db

so each time I click I want to clear off the previous textboxes.. ?

For Each childrow In childTable.Rows
Dim childID As Integer = childTable.Rows(p).Item(i)
Panel1.Visible = False
Dim txtVar As Object = "txt" & childID
txtVar = New TextBox
txtVar.Text = "Text"
txtVar.Location = New System.Drawing.Point(200, x)
txtVar.Size() = New System.Drawing.Size(70, 20)
With Me.Controls
.Add(txtVar)
End With


x = x + 23
Next
 
Back
Top