473,785 Members | 2,354 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Picturebox Array (VB Express)

Hi there,

Is it possible to create an array of picturebox controls during
run-time. I wish to create a new image/picturebox everytime a user
clicks the button on a form, and they need to be objects so that the
user can move/drag them around.
The only examples I can find dont work as I am using VB Express (2005?)

and the examples are writting in VB6.
Is anyone able to help please?
Toby.

Jan 4 '07 #1
5 4563
At class level in your form:

Private m_pictureboxes As New ArrayList()

In the Click event handler of your button:

Dim _pic As New PictureBox

_pic.Location = New System.Drawing. Point(<x>, <y>)

_pic.Size = New System.Drawing. Size(<w>, <h>)

' set any other properties as required

' wire up the desired event handlers
AddHandler _pic.<event>, AddressOf <event_handle r>

Me.Controls.Add (_pic)

m_pictureboxes. Add(_pic)

where:

<xand <yare the coordinates of the desired iniial position
<wand <hare the width and height values for the desired size
<eventis the desired event
<event_handleri s the desired event hander (predefined)

e.g.

Private Sub PictureBox_Clic k(ByVal sender As System.Object, ByVal e As
System.EventArg s)

CType(sender, PictureBox).Bac kColor = Color.CadetBlue

End Sub

If you 'add' 3 pictureboxes by clicking the button three times and then
click a picturebox, it's background colour will change.

Obviously you will have to implement a mechanism for varying the <xand <y>
values otherwise all the pictureboxes will be drawn in the same place.
<to**@mkkbb.f9. co.ukwrote in message
news:11******** **************@ 31g2000cwt.goog legroups.com...
Hi there,

Is it possible to create an array of picturebox controls during
run-time. I wish to create a new image/picturebox everytime a user
clicks the button on a form, and they need to be objects so that the
user can move/drag them around.
The only examples I can find dont work as I am using VB Express (2005?)

and the examples are writting in VB6.
Is anyone able to help please?
Toby.

Jan 4 '07 #2
Toby,

Instead of the label1 and label2 you can use pictureboxes

http://www.vb-tips.com/dbpages.aspx?...1-47ef665ea0c2

Cor
<to**@mkkbb.f9. co.ukschreef in bericht
news:11******** **************@ 31g2000cwt.goog legroups.com...
Hi there,

Is it possible to create an array of picturebox controls during
run-time. I wish to create a new image/picturebox everytime a user
clicks the button on a form, and they need to be objects so that the
user can move/drag them around.
The only examples I can find dont work as I am using VB Express (2005?)

and the examples are writting in VB6.
Is anyone able to help please?
Toby.

Jan 4 '07 #3
Thanks very much for the responses, looks like I was almost there, but
your examples have been a godsend! :-)

Thanks again.

Jan 4 '07 #4

Stephany Young wrote:
At class level in your form:

Private m_pictureboxes As New ArrayList()

In the Click event handler of your button:

Dim _pic As New PictureBox

_pic.Location = New System.Drawing. Point(<x>, <y>)

_pic.Size = New System.Drawing. Size(<w>, <h>)

' set any other properties as required

' wire up the desired event handlers
AddHandler _pic.<event>, AddressOf <event_handle r>

Me.Controls.Add (_pic)

m_pictureboxes. Add(_pic)

where:

<xand <yare the coordinates of the desired iniial position
<wand <hare the width and height values for the desired size
<eventis the desired event
<event_handleri s the desired event hander (predefined)

e.g.

Private Sub PictureBox_Clic k(ByVal sender As System.Object, ByVal e As
System.EventArg s)

CType(sender, PictureBox).Bac kColor = Color.CadetBlue

End Sub

If you 'add' 3 pictureboxes by clicking the button three times and then
click a picturebox, it's background colour will change.

Obviously you will have to implement a mechanism for varying the <xand <y>
values otherwise all the pictureboxes will be drawn in the same place.
<to**@mkkbb.f9. co.ukwrote in message
news:11******** **************@ 31g2000cwt.goog legroups.com...
Hi there,

Is it possible to create an array of picturebox controls during
run-time. I wish to create a new image/picturebox everytime a user
clicks the button on a form, and they need to be objects so that the
user can move/drag them around.
The only examples I can find dont work as I am using VB Express (2005?)

and the examples are writting in VB6.
Is anyone able to help please?
Toby.
Stepahnie,

How can I reference the image property of a picturebox in an array. I
would ahve assumed it was:

m_picturebox(1) .image

but that brings up errors. How can I change properties of these
controls in the array?

Thanks.

Jan 4 '07 #5
What 'errors'?
<to**@mkkbb.f9. co.ukwrote in message
news:11******** *************@i 80g2000cwc.goog legroups.com...
>
Stephany Young wrote:
>At class level in your form:

Private m_pictureboxes As New ArrayList()

In the Click event handler of your button:

Dim _pic As New PictureBox

_pic.Location = New System.Drawing. Point(<x>, <y>)

_pic.Size = New System.Drawing. Size(<w>, <h>)

' set any other properties as required

' wire up the desired event handlers
AddHandler _pic.<event>, AddressOf <event_handle r>

Me.Controls.Add (_pic)

m_pictureboxes. Add(_pic)

where:

<xand <yare the coordinates of the desired iniial position
<wand <hare the width and height values for the desired size
<eventis the desired event
<event_handleri s the desired event hander (predefined)

e.g.

Private Sub PictureBox_Clic k(ByVal sender As System.Object, ByVal e As
System.EventAr gs)

CType(sender, PictureBox).Bac kColor = Color.CadetBlue

End Sub

If you 'add' 3 pictureboxes by clicking the button three times and then
click a picturebox, it's background colour will change.

Obviously you will have to implement a mechanism for varying the <xand
<y>
values otherwise all the pictureboxes will be drawn in the same place.
<to**@mkkbb.f9 .co.ukwrote in message
news:11******* *************** @31g2000cwt.goo glegroups.com.. .
Hi there,

Is it possible to create an array of picturebox controls during
run-time. I wish to create a new image/picturebox everytime a user
clicks the button on a form, and they need to be objects so that the
user can move/drag them around.
The only examples I can find dont work as I am using VB Express (2005?)

and the examples are writting in VB6.
Is anyone able to help please?
Toby.

Stepahnie,

How can I reference the image property of a picturebox in an array. I
would ahve assumed it was:

m_picturebox(1) .image

but that brings up errors. How can I change properties of these
controls in the array?

Thanks.

Jan 4 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
5326
by: Geoff Cox | last post by:
Hello, Can I separately declare and initialize a string array? How and where would I do it in the code below? It was created using Visual C++ 2005 Express Beta 2 ... In C# I would have private string myArray;
11
2271
by: Geoff Cox | last post by:
Hello, I am trying to get a grip on where to place the initialization of two arrays in the code below which was created using Visual C++ 2005 Express Beta 2... private: static array<String^>^ LHSquestions = gcnew array<String^> {"question 1","question 2"}; private: static array<String^>^ RHSquestions = gcnew array<String^> {"question 1",
4
9246
by: Charles | last post by:
Hello Everyone, I have been gettting great feedback from microsoft.public.vc.language group but after doing more searching I think my post should be directed to this group. I am trying to make a simple gif animation using VC++ and 13 different gif files and a timer. I am new to VC++ but played around with C++ for a few years. I am using Microsoft Visual Studio 2005 (VC++).
0
1232
by: akumarp2p | last post by:
Hi Experts I have created a panel at design time. At Run time i make array of PictureBox and add image to that pictureBox array control. Now I have problem, How to Create Event on that dynamin PictureBox. Pls Help Me with instruction as well as code. Thanks Mr. Kumar krashishroa@yahoo.co.in
0
953
by: Feride | last post by:
hello, i'm trying to show a pictureBox named pb1 on some other pictureBoxes which are the elements of a pictureBox array called pbs. To watch the differences, i made use of a timer. here are the codes. int num=0; private void t_Tick(object sender, EventArgs e){ PictureBox pbs = new PictureBox;
6
25815
by: robusto33 | last post by:
Hi everyone, I'm really new to C#.net development, especially for win32 applications. I'm basically making a board game and was wondering if anyone could help me out with this predicament: I have a dynamically created array based on the size of the Board (13x13 or 19x19). I can make the array fine and position the pictureBoxes over the background, but I want to be able to change the properties of all the pictureBoxes based on a Click event. ...
2
2828
by: Boki | last post by:
Hi All, I remember in VB6, we can create any component array just by copy and paste, and the IDE will ask us to use a component array or not. I did the same thing on C#, it will auto create the next picturebox, the name is something like: picturebox2. if they are not array, I will be very difficult to program them ... Best regards,
4
3820
by: munibe | last post by:
Hi, i have a problem about picturebox control. if you may help me, i will be so happy. i have a picturebox named pic_map, and i added a button named customer_button, my wish is to add a new small picturebox on the map_picture and the new added picturebox should have click event to get the location of it when it is clicked. i have written some code in C# but when clicking the small picturebox it just gets the location of the last added one,...
4
3714
by: Jim McGivney | last post by:
In C# on Form1 I genetate an array of PictureBoxes and populate each with an image as seen in the code below. Later on I want to access a specific PictureBox to change its image, but I keep getting the error "The name 'PictureBox1' does not exist in the current context" The code I use to try to access the PictureBox is "PictureBox1.Image = HoldBitMap; " where kount is an integer. I know the answer is probably in using the Controls...
0
9646
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9484
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10350
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10157
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10097
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8983
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7505
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5386
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3658
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.