Control Arrays Question

D

Diarmuid

Are there control arrays in vb.net 2005?
Maybe some one could help me out with an example. I know how to this in VB6.
My database is called Planner.mdb
There is a table called Weekdays.
I want to read the first record in, and use that to set my labels as follows
me.lblDay1 = WeekDays!Day1
me.lblDay2 = WeekDays!Day2

and so on. In VB6 I would have done this in a for loop. Something like
me.lblDays(iLoop_ = rsWeekdays("Day" & iLoop)

How would I do that using the new datasets?

Thanks
Diarmuid
 
C

Chris

Diarmuid said:
Are there control arrays in vb.net 2005?
Maybe some one could help me out with an example. I know how to this in VB6.
My database is called Planner.mdb
There is a table called Weekdays.
I want to read the first record in, and use that to set my labels as follows
me.lblDay1 = WeekDays!Day1
me.lblDay2 = WeekDays!Day2

and so on. In VB6 I would have done this in a for loop. Something like
me.lblDays(iLoop_ = rsWeekdays("Day" & iLoop)

How would I do that using the new datasets?

Thanks
Diarmuid

Either make your own array:
dim Controls(X) as Controls
Controls(0) = lblDay1

or use the form's control array:
Me.Controls

if you use the form's control array you have to check if it is a
textbox/labelbox or not before using it, since it has all the controls
in it.

Chris
 
C

Cor Ligthert [MVP]

Diarmuid,

This is an often spread misunderstanding given by VB6 people.

VB classic had arrays from controls on a form
VBNet (starting direct with version 2002) has an array for every control
including the Form which is a control.

Therefore and let us say that you put your labels direct on the form, you
can do something as beneath roughly typed in this message

\\\
For each ctr in me.controls
If Typeoff ctr Is Label then
ctr.Text = ds.Tables("Whatever").Rows(0).Item(ctr.tag.ToString)
End if
Next
///
(You have set the datatable columnames than in the tags)

Be aware that I wrote every control has its array of controls and therefore
if the labels are by instance on a panel you have to do mypanel.controls

I hope this helps,

Copr

I hope this helps,

Cor
 
D

Diarmuid

Ok, I get what you mean. I can just check for more specific label if needs
be.
Thanks
Diarmuid
 
P

prajesh.shreshta

hi
thanx ,yes it did help me.but now the huge problem is how to save Image
in sql. i tried be creating a table with the column with data type
"image" but it didnt work.but friend of mine told me that i can use
"blob" data type but in sql there is no such data type named "blob"
so if you can help me to keep image in data base sql
 

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