is it possable to build a windows form from a DB at run time?

Populate the windows form with controls from a database query?
agent_xpAsked:
Who is Participating?
 
manchCommented:
Create the Database structure as Follows

Table : FormControlDetails

Columns

1. ControlName           2. ControlText
3. Left                        4. Top
5. Container                6. ContainerObject
7. Width                      8. Height
   etc. Columns as required by u

At run time populate the data of the database (from the table specified) on initialise event
and now start creating controls according to this data (at run time) on the Load event of the Form

Thus u will be able to create the controls dynamically

U can also create a Form Control in the same manner (in that case u have to choose the other events or Main Subs)


0
 
bman9111Commented:
yes.....depending on how u want it....

I have created one before for a client that created buttons and links from the database too..

example

had 2 fields

field1                  field2
google                www.google.com
yahoo                 www.yahoo.com
pc                      c:\

and what would happen is my form would read the program and create 3 buttons on the form and when the user click on the button it would call what ever was in field2.

example
user click google button and it would take them to google.


a sample code for having a control created at runtime of the form and not by drag or drop would be...

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim b = New Button()
        b.Text = "Test Button"
        b.Size = New Size(100, 100)
        b.Location = New Point(0, 5)
        Me.Controls.Add(b)
    End Sub




0
 
bman9111Commented:
the code I provided does address the issue he/she was asking....

If anything I would like to see points be given to someone....
0
 
bman9111Commented:
lol
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.