GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Microsoft  >  Visual Basic
Go To First  |  Previous Question  |  Next Question 
 Visual Basic  |  Question 420 of 453    Print  
Q. How we can create a controls like textboxes or buttons on runtime according or depends to the output from the database?

  
Total Answers and Comments: 3 Last Update: June 23, 2007     Asked by: Akshay 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
July 14, 2006 01:29:17   #1  
Karthikeyan        

try this one

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


 
Is this answer useful? Yes | No
July 19, 2006 03:21:04   #2  
vinod_arya Member Since: September 2005   Contribution: 6    

RE: Q. How we can create a controls like textboxes or ...

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


 
Is this answer useful? Yes | No
June 23, 2007 05:56:46   #3  
Atin Srivastava        

RE: Q. How we can create a controls like textboxes or ...
Dim ctl as control
set ctl Form1.Controls.add("Vb.Textbox" "text1" form1)
ctl.visible true

 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape