473,699 Members | 2,768 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how can i create objects at runtime in a picturebox?

13 New Member
I want to create an array of lines when my form loads inside of a picture box, without having to copy-paste on the form. so far, i have created a line on the form and set its index to 0. then, in the code i put

For LinCount = 1 To (somenumber)
Load BoxlinBorder(Li nCount)
Next LinCount

which creates the lines without any errors. I still need to put the lines into a picturebox somehow, and i would like to declare everything in code, not on the form. That is, is there some way to create the line array without having to make a line on the form first? Any help is appreciated.

Thanks,
vfiroiu
May 19 '07 #1
13 3442
Dököll
2,364 Recognized Expert Top Contributor
Expand|Select|Wrap|Line Numbers
  1. For LinCount = 1 To (somenumber)
  2. Load BoxlinBorder(LinCount)
  3. Next LinCount
That is, is there some way to create the line array without having to make a line on the form first? Any help is appreciated.

Thanks,
vfiroiu
Not sure how this would work, vfiroiu, but have you tried doing this in form load?
May 19 '07 #2
vfiroiu
13 New Member
Yes, the above code is in Form - Activate. By the way, BoxlinBorder() is a line array with only one element (BoxlinBorder(0 ), which i created in the form), I don't think i made that clear.
May 19 '07 #3
Killer42
8,435 Recognized Expert Expert
Yes, the above code is in Form - Activate. By the way, BoxlinBorder() is a line array with only one element (BoxlinBorder(0 ), which i created in the form), I don't think i made that clear.
Have you made any progress on this?

I see the problem. I've loaded arrays of controls like this at runtime myself, but have always done so by creating the "zeroth" element at design time and simply loading more occurrences at runtime. Is there a real need to avoid this, or is it just that you're determined to "beat this thing"? :-)

Anyway, I'll have a play around and see whether I can come up with anything.
May 22 '07 #4
Killer42
8,435 Recognized Expert Expert
Oh, by the way. I think (not sure) that you can place the line control into a picturebox by setting the line's .Container property.
May 22 '07 #5
Killer42
8,435 Recognized Expert Expert
Ok, I've got something for you.

Here's some code which creates a line control at runtime. I've done it as the first element of an array, simply because arrays are so powerful and convenient. But it was all done at runtime. Give it a try, it'll give you a basis to work from.

Expand|Select|Wrap|Line Numbers
  1. Option Explicit
  2.  
  3. Dim MyLine() As Control
  4.  
  5. Private Sub Form_Load()
  6.   ReDim MyLine(0 To 5)
  7.   Set MyLine(0) = Form1.Controls.Add("VB.Line", "SomeName", Form1)
  8.   With MyLine(0)
  9.     .X1 = 0
  10.     .X2 = 500
  11.     .Y1 = 0
  12.     .Y2 = 500
  13.     .Visible = True
  14.     .BorderColor = 0&
  15.     ' To move the line control into picturebox Picture1, do this...
  16.     ' Set .Container = Picture1
  17.   End With
  18. End Sub
May 22 '07 #6
vfiroiu
13 New Member
hmmm, I've tried the .Container to put the line in the picture box.... but i suppose i had the syntax wrong. I will try this, thanks for the help!
May 23 '07 #7
Killer42
8,435 Recognized Expert Expert
hmmm, I've tried the .Container to put the line in the picture box.... but i suppose i had the syntax wrong. I will try this, thanks for the help!
You probably left out the Set keyword - same mistake I made until I checked the doco.
May 23 '07 #8
vfiroiu
13 New Member
by the way: what is the purpose of "somename"?
May 24 '07 #9
vfiroiu
13 New Member
I now get an error when i try to use expressions like MyLine.Count
It isn't terribly important, but i would like to know why and how to fix it, if possible

also: i get an error when i try to

for lincount = 1 to somenumber
Load MyLine(lincount )
next lincount
May 24 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

0
1209
by: Jessard | last post by:
Hi Guys and Girls, Does anybody no how to resize a picturebox control at runtime? When i say resize, i mean the actual edges of the picturebox, ie. being able to drag the edges out just as if you went to the ends of a form, the cursor changes to a double ended arrow and you click and drag it as you want. Any suggestions would be good, Jesse
7
8859
by: dog | last post by:
I've seen plenty of articles on this topic but none of them have been able to solve my problem. I am working with an Access 97 database on an NT4.0 machine, which has many Access reports. I want my users to be able to select a report, click on a command button on a form, which will then automatically create the report as a pdf file and save it to the user's machine. I am using Adobe Acrobat (5.0 I think) and have Adobe Distiller as a
0
3163
by: 6tc1 | last post by:
Hi all, I've got a UserControl that contains a few PictureBox objects. If I click on outside of the Picture in the UserControl, the scrolling with the mouse button works - however, no amount of clicking on the PictureBox objects will get that scrolling working. However, after I click on outside of the PictureBox object, then click as many times as I like on the PictureBox the scrolling with the mouse wheel continues to work. I found...
15
26508
by: Amit D.Shinde | last post by:
I am adding a new picturebox control at runtime on the form How can i create click event handler for this control Amit Shinde
6
4751
by: Rich | last post by:
Hello, I want to simulate the dynamic thumbnail display of Windows Explorer (winxp) on a form or pannel container. If I place a picture box on my container form/pannel and dimension it to the size of a thumbnail and set the sizemode to Stretch -- I get one thumbnail. I want to retrieve all the picture files (jpg, bmp) in a directory into an array list and then display this list as thumbnails on my form dynamically. So my question is...
5
2271
by: Paul M | last post by:
Hi I need to create a map for a room (chairs, bed, TV, forniture, etc). All object allready exists like png images. I need to create a map for each room, i mean the user need to create. How can I do this? TIA, Paul
0
1279
by: Victor Reboucas | last post by:
Hi, I'm a VB.Net developer and cannot find a way to create a bipmap from a pointer... My application does video rendering using Windows media encoder (that's out of the content of this message). Using a "DataView" object I can attach a "video viewer" to about every control in a Form, using a "integer reference" to attach the viewer object to the control you want to use as a viewer. Question: is there any way to use the...
1
1337
by: =?Utf-8?B?TWFyaW8=?= | last post by:
hi, i would like to add pictureboxes during runtime, but there should not be a specific variable for each picturebox becouse i don't know how much it will be. so i declared a collection referencing on one var declared as picturebox. it works fine to add the controls this way. now i would like to implement one picturebox click handle for each added picturebox and i have no idea how to do this. Friend WithEvents Device As PictureBox
10
7415
by: eddie tan | last post by:
Hi, I have a picturebox with graphics drawn from different objects. In one object I used Pen P1; P1 = new Pen(Color.Blue, 3); Graphics g = null; g = Graphics.FromImage(image.Image); g.DrawPath(P1, Wirepath);
0
8686
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
8615
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
9033
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...
0
8882
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7748
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...
0
4627
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3057
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2345
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2009
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.