Connecting Tech Pros Worldwide Forums | Help | Site Map

Create a textbox control array from sql table

OuTCasT's Avatar
Needs Regular Fix
 
Join Date: Jan 2008
Location: South Africa
Posts: 361
#1: Jan 21 '09
Hi.
I want to create an array that add's textboxes dynamically to a windows form according to an sql tables contents.

would this be possible ?

OuTCasT's Avatar
Needs Regular Fix
 
Join Date: Jan 2008
Location: South Africa
Posts: 361
#2: Jan 21 '09

re: Create a textbox control array from sql table


I was playing around and found that this would work.
Only one problem. How would i get the textboxes underneath each other instead of next to each other.

Expand|Select|Wrap|Line Numbers
  1.  
  2. For i As Integer = 0 To sqlDS.Tables("customers").Rows.Count - 1
  3. Dim tb As New Windows.Forms.TextBox
  4. With tb
  5. .Visible = True
  6. .Size = New Size(30, 30)
  7. .Location = New Point(40 * i, 40)
  8. .Name = "txtEarnings" + i.ToString
  9. MsgBox(.Name)
  10. .Text = sqlDS.Tables("customers").Rows(i).Item("customername")
  11. Me.Controls.Add(tb)
  12. End With
  13.  
debasisdas's Avatar
Moderator
 
Join Date: Dec 2006
Location: Bangalore ,India
Posts: 7,511
#3: Jan 21 '09

re: Create a textbox control array from sql table


you need to change the location property.
OuTCasT's Avatar
Needs Regular Fix
 
Join Date: Jan 2008
Location: South Africa
Posts: 361
#4: Jan 21 '09

re: Create a textbox control array from sql table


yes thanks i did change the location.
Reply


Similar Visual Basic 4 / 5 / 6 bytes