Q. How we can create a controls like textboxes or buttons on runtime according or depends to the output from the database?

Showing Answers 1 - 5 of 5 Answers

Karthikeyan

  • Jul 14th, 2006
 

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

If TextBox1.Text = "1" Then

Dim textbox As New System.Windows.Forms.TextBox

textbox.Name = "one"

textbox.Text = "hello"

Me.Controls.Add(textbox)

Else

Dim button As New System.Windows.Forms.Button

button.Enabled = True

button.Name = "Button1"

button.Text = "New Button"

Me.Controls.Add(button)

End If

End Sub

  Was this answer useful?  Yes

vinod_arya

  • Jul 19th, 2006
 

By creating array of controls.

Example u want to display as many text boxes as the number of records in table u create a text box on Form set it Index to 0.

and while fetching records, let us say rs is the recordset and text1 is the control array

dim ndx as integer

ndx=1

while not rs.eof

load text1(ndx)

text1(ndx).top=text1(ndx-1).top+text1(ndx).height

text1(ndx).visible=true

rs.movenext

wend

  Was this answer useful?  Yes

Atin Srivastava

  • Jun 23rd, 2007
 

Dim ctl as control
set ctl=Form1.Controls.add("Vb.Textbox","text1",form1)
ctl.visible=true

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions