473,326 Members | 2,111 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Drawing pictureboxes problem

MrMancunian
569 Expert 512MB
Hi,

I'm facing a weird problem. I want to draw 15 pictureboxes in a horizontal line. I created an array of 15 boxes and in a loop, I assign it a picture and I set the location. Then I add the box to the form.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  2.         Dim a, b As Integer
  3.         Dim picLucifer(14) As PictureBox
  4.         b = 1
  5.         For a = 0 To 14
  6.             picLucifer(a) = New PictureBox()
  7.             picLucifer(a).Image = My.Resources.middlefinger
  8.             picLucifer(a).Location = New Point(20, b)
  9.             picLucifer(a).Visible = True
  10.             b = b + 50
  11.             Me.Controls.Add(picLucifer(a))
  12.         Next
  13.     End Sub
  14.  
Now, the problem is in the picLucifer(a).Location = New Point(20, b) row. When I assign a fixed value to the X and let the Y be a variable, everything is fine. I get a vertical list of 15 pictures. However, when I switch the X and the Y, so the X as variable and the Y fixed, it just shows me one picture. So,

Expand|Select|Wrap|Line Numbers
  1. picLucifer(a).Location = New Point(20, b)
  2.  
works, but

Expand|Select|Wrap|Line Numbers
  1. picLucifer(a).Location = New Point(b, 20)
  2.  
doesn't work. Does anyone have an idea why?

Thanks!

Steven
Nov 21 '08 #1
5 1094
Plater
7,872 Expert 4TB
Is there some "scrolling" property not set correctly on your Form object?
Are your pictures really only <=50pixels wide?
Did you set a breakpoint and verify that a unique point was being created for each picture?

Nice choice of picture by the way.
Nov 21 '08 #2
MrMancunian
569 Expert 512MB
Is there some "scrolling" property not set correctly on your Form object?
Are your pictures really only <=50pixels wide?
Did you set a breakpoint and verify that a unique point was being created for each picture?

Nice choice of picture by the way.
There is no scrolling propery on the object. This is actually the only piece of code in the solution, as I am just trying and playing around. The size of the picture, which is an emoticon (http://www.stevenvandenbrink.nl/middlefinger.gif), is only 37 x 21. I set breakpoints and the integer b does change...

Steven
Nov 21 '08 #3
tlhintoq
3,525 Expert 2GB
@MrMancunian
So when it does change, which of your 14 PictureBoxes is actually being placed? The first instance, the last?

What about changing the calculation of your horizontal offset to include the Bounds.Left of the form its going onto? In theory the left edge should be zero, right? So it shouldn't make a difference whether you include it or not. But if the left edge has some weird geometry for some reason, and the left edge is -70, then your first several boxes will be drawn in a non-visible space.

You might also consider using different images in each box so you can tell which box is being drawn in which location. Having them all come up as .middlefinger makes it harder to tell which is which.
Nov 23 '08 #4
Plater
7,872 Expert 4TB
Must be a VB thing because mine worked fine?

Also:
New Point(20, b)
Is the setup to produce a vertical grouping (one below the previous going downward) and not horizontal
Nov 24 '08 #5
MrMancunian
569 Expert 512MB
Hi,

I solved the problem. I had to set the size of the picturebox to be the same as the image I put into the box. Thanks for the help :-)

Steven
Nov 25 '08 #6

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

Similar topics

7
by: Scott Mackay | last post by:
Hi, I'm using visual studio dotnet 2002 programming in vb can anyone tell me how I can handle the mousedown event for pictureboxes I create dynamically at runtime? I've tried setting the...
8
by: Benoit Martin | last post by:
I had to draw my own control because I couldn't find any control doing what I wanted it to do. This control has a grid that I need to have control over. To do that, I draw each line of the grid...
5
by: lgbjr | last post by:
Hello All, I have several Pictureboxes (linked to an AccessDB) on a VB.NET form. I would like to use a context menu to allow the user to open the picture in their default picture viewer or...
1
by: Rohan | last post by:
Hi There, Is it possible to rotate or resize pictureboxes, labels, textboxes at runtime? And I even wanted to make textbox and label controls Transperent ?
4
by: KitKat | last post by:
Problem trying to figure this out, using a combo box selection I need to go to each folder, Cam 1, Cam 2, Cam 4, Cam 6, Cam 7,and Cam 8 and display each picture (from selection) from each folder...
2
by: Pascal | last post by:
Je veux que mes label soit transparent aussi sur mes picturebox alors j'écris : i want my labels to be transparent on my pictureboxes so i wrote : Private Sub Form1_Load(ByVal sender As Object,...
0
by: Blarneystone | last post by:
I am pulling my hair out over this one. I've got a picturebox with just a simple gradient as the background for my interface. It is in 16bit RGB color. I've created some pictures I'll use as...
6
by: =?Utf-8?B?bGpsZXZlbmQy?= | last post by:
I am implementing an Office 2007 – like interface, including the ability to change colors. One issue that I have is that scrollbars look poor if the application color theme (e.g., Black) does...
2
by: djpaul | last post by:
Heey! For my program i need to create pictureboxes on the fly. After adding pictures to the database with a surten folder you can eddit the pictures or the text that's with it. But when i select a...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.