Home All Groups Group Topic Archive Search About

creating pictureboxes on the fly

Author
6 Oct 2006 12:14 PM
John Devlon
Hi,

I'm trying to fill a form in visual basic .net with pictureboxes
Unfortunately, it doesn't work... the boxes don't show

Can anyone please help me ?


Dim x As Integer = 0
Dim myCollection As List(Of PictureBox) = New List(Of PictureBox)
Dim Location As Integer = 50

For x = 0 To 5
Dim myBox As PictureBox = New PictureBox
myBox.SetBounds(50, Location * x, 34, 34)
myBox.BackColor = Color.Black
myBox.BringToFront()
myCollection.Add(myBox)
myBox = Nothing
Next

Thanx,

John

Author
6 Oct 2006 12:36 PM
rowe_newsgroups
throw in the following:

Me.Controls.Add(MyBox)

Thanks,

Seth Rowe

John Devlon wrote:
Show quoteHide quote
> Hi,
>
> I'm trying to fill a form in visual basic .net with pictureboxes
> Unfortunately, it doesn't work... the boxes don't show
>
> Can anyone please help me ?
>
>
> Dim x As Integer = 0
> Dim myCollection As List(Of PictureBox) = New List(Of PictureBox)
> Dim Location As Integer = 50
>
> For x = 0 To 5
> Dim myBox As PictureBox = New PictureBox
> myBox.SetBounds(50, Location * x, 34, 34)
> myBox.BackColor = Color.Black
> myBox.BringToFront()
> myCollection.Add(myBox)
> myBox = Nothing
> Next
>
> Thanx,
>
> John
Author
6 Oct 2006 12:42 PM
John Devlon
Many thanx,

I just figgerd it out myself...

John


Show quoteHide quote
"rowe_newsgroups" <rowe_em***@yahoo.com> schreef in bericht
news:1160138197.330948.161210@i3g2000cwc.googlegroups.com...
> throw in the following:
>
> Me.Controls.Add(MyBox)
>
> Thanks,
>
> Seth Rowe
>
> John Devlon wrote:
>> Hi,
>>
>> I'm trying to fill a form in visual basic .net with pictureboxes
>> Unfortunately, it doesn't work... the boxes don't show
>>
>> Can anyone please help me ?
>>
>>
>> Dim x As Integer = 0
>> Dim myCollection As List(Of PictureBox) = New List(Of PictureBox)
>> Dim Location As Integer = 50
>>
>> For x = 0 To 5
>> Dim myBox As PictureBox = New PictureBox
>> myBox.SetBounds(50, Location * x, 34, 34)
>> myBox.BackColor = Color.Black
>> myBox.BringToFront()
>> myCollection.Add(myBox)
>> myBox = Nothing
>> Next
>>
>> Thanx,
>>
>> John
>
Author
6 Oct 2006 12:40 PM
Robinson
Show quote Hide quote
"John Devlon" <johndev***@hotmail.com> wrote in message
news:LMrVg.114873$Ja3.1615998@phobos.telenet-ops.be...
>
> Hi,
>
> I'm trying to fill a form in visual basic .net with pictureboxes
> Unfortunately, it doesn't work... the boxes don't show
>
> Can anyone please help me ?
>
>
> Dim x As Integer = 0
> Dim myCollection As List(Of PictureBox) = New List(Of PictureBox)
> Dim Location As Integer = 50
>
> For x = 0 To 5
> Dim myBox As PictureBox = New PictureBox
> myBox.SetBounds(50, Location * x, 34, 34)
> myBox.BackColor = Color.Black
> myBox.BringToFront()
> myCollection.Add(myBox)
> myBox = Nothing
> Next
>
> Thanx,
>

Hi,

You need to add your box to the control collection of the form/panel/control
it is displayed upon.



Robin
Author
6 Oct 2006 12:40 PM
John Devlon
I found it myself ...

just ad
Me.Controls.Add(myBox)

It works...

John



Show quoteHide quote
"John Devlon" <johndev***@hotmail.com> schreef in bericht
news:LMrVg.114873$Ja3.1615998@phobos.telenet-ops.be...
>
> Hi,
>
> I'm trying to fill a form in visual basic .net with pictureboxes
> Unfortunately, it doesn't work... the boxes don't show
>
> Can anyone please help me ?
>
>
> Dim x As Integer = 0
> Dim myCollection As List(Of PictureBox) = New List(Of PictureBox)
> Dim Location As Integer = 50
>
> For x = 0 To 5
> Dim myBox As PictureBox = New PictureBox
> myBox.SetBounds(50, Location * x, 34, 34)
> myBox.BackColor = Color.Black
> myBox.BringToFront()
> myCollection.Add(myBox)
> myBox = Nothing
> Next
>
> Thanx,
>
> John
>