Creating text boxes on the fly?

B

BurntWithTime

Hello everyone,
Please can anyone tell me if it is possible for a VB.NET application to
check a database and then create textboxes on a form that correspond to
those records on the database? For example, say I had a table in a DB that
contained movie subjects: Horror, Sci-Fi, Comedy etc. Would it be possile
for the VB app to look at these and then create the text boxes Horror,
Sci-Fi and Comedy?

Thanks,
BWT
 
P

pvdg42

BurntWithTime said:
Hello everyone,
Please can anyone tell me if it is possible for a VB.NET application to
check a database and then create textboxes on a form that correspond to
those records on the database? For example, say I had a table in a DB that
contained movie subjects: Horror, Sci-Fi, Comedy etc. Would it be possile
for the VB app to look at these and then create the text boxes Horror,
Sci-Fi and Comedy?

Thanks,
BWT
Yes, you can. If you're wondering about the code, just create a simple VB
Windows app, place a textbox on the form, then have a look at the generated
code. In VS 2005, display all files, then look at <your form
name>.designer.vb
 
C

Cor Ligthert [MVP]

Peter,

In my idea you cannot do anymore what the OP is asking, in classic VB there
is I thought the name was a DataBaseProject or something like that, that
makes a complete form for you using the database. Now it is back in 2.0
with, however there it uses the datagridview and no textboxes.

http://www.vb-tips.com/dbpages.aspx?ID=1139f14a-c236-4ad7-8882-b1ed16424252

I was asking myself why I had not answered this question and than felt the
quarter.

This is an often used phrase in Dutch. (Toen viel het kwartje) although the
quarter does not exist anymore in the Euro.

In fact he is in my opinion asking for Office MS Access

Cor
 
P

pvdg42

Cor Ligthert said:
Peter,

In my idea you cannot do anymore what the OP is asking, in classic VB
there is I thought the name was a DataBaseProject or something like that,
that makes a complete form for you using the database. Now it is back in
2.0 with, however there it uses the datagridview and no textboxes.

http://www.vb-tips.com/dbpages.aspx?ID=1139f14a-c236-4ad7-8882-b1ed16424252

I was asking myself why I had not answered this question and than felt the
quarter.

This is an often used phrase in Dutch. (Toen viel het kwartje) although
the quarter does not exist anymore in the Euro.

In fact he is in my opinion asking for Office MS Access

Cor
I thought he was asking if text boxes could be created in code, which they
can. The issue of where to obtain the data to populate the text property is
secondary. If the OP wants to write the code to create a textbox in a method
called based on some event occurring, then populate the text property of the
new textbox with data (or metadata) retrieved from a database, that's easily
done as well.

Of course, if what the OP is looking for is automatic form generation,
you're right.
 
B

BurntWithTime

Thanks for the replies people.
There seems to be some confusion. I do not want to create the entrie form
automatically, just create the text boxes automatically. So basically the
form is blank, but when it is loaded, the program checks the database, and
creates the text boxes that are needed. Does this make it any clearer?
 
P

pvdg42

BurntWithTime said:
Thanks for the replies people.
There seems to be some confusion. I do not want to create the entrie form
automatically, just create the text boxes automatically. So basically the
form is blank, but when it is loaded, the program checks the database, and
creates the text boxes that are needed. Does this make it any clearer?
As I answered originally, yes, you can create the textboxes you need
programmatically (IOW, your program will create the needed controls after
querying the database to see what is needed).

My first response told you where to find example code for control creation,
if you need something more explicit, ask away.
 
C

Cor Ligthert [MVP]

Burnt,
So basically the form is blank, but when it is loaded, the program checks
the database, and creates the text boxes that are needed. Does this make it
any clearer?

In my idea not, in my idea is Peter answering you exactly how you creates
text boxes on the fly.

However, although it is in your subject is in my idea in your text not what
at least in these newsgroups is called "creating text boxes on the fly".

Or you should make yourself a program as Peter wrotes, that checks the
content of the datatables and make as many textboxes as there are
datacolumns in your dataset.

Something as

\\\
For each dc as datacolum in myDataTable.DataColumns
dim txtBox as new Textbox
txtBox.Name is dc.ColumName
'set the position and other probertis of that textbox
Controls.Add(txtBox)
Next
///

Than you have what you ask.

With that hoping to end at least my confusion.

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top