OK, here's where I'm at -
I've created a panel (400x400) with 324 PictureBoxes (yes, unfortunately I felt the need to use a 18x18 grid of PictureBoxes).
Each PictureBox has some code which changes the colour when pressed. Below is an example for PictureBox2:
Private Sub PictureBox2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox2.Click paintme(PictureBox2) End Sub |
And the code for painting:
Public Function paintme(ByVal square) square.BackColor = ColorDialog1.Color End Function |
I need some script which changes the color of multiple PictureBoxes when they are selected somehow (dragging ) apon the click of a mouse.
I need to know if this is at all possible - I have another idea to use only 1 PictureBox, and use the CreateGraphics() control to fill the squares of an invisible grid. I just need soe guidelines.
Thank you very much for your time,
Robert Hoath (hoathdesigns@gmail.com)

PictureBox + Color
Epilif
Global Bob(20,20) as Integer
Global MX as Integer
Global MY as Integer
This defines 400 different 'Bob's. Imagine a grid of integers, 20 by 20. (It's actually 21 by 21 because 0 counts). MX and MY is to keep track of where you're mouse is.
Now in form1.
You only need to make one, big, perfect square, picturebox1. And you type the following code under Picture1_Mousemove:
MX=X
MY=Y
Make two pictureboxes, picturebox2(0) and picturebox2(1). The brackets (0) and (1) mean they are arrays, just like Bob. You make them by copy and pasting picturebox2 once.
Here's where it gets 'fun'. Under Picture1_click, you fill in this code:
Bob(CInt((MX / Picture1.Width) * 20 + 0.5), CInt((MY / Picture1.Height) * 20 + 0.5)) = CInt(Rnd)
For X = 0 To 19
For Y = 0 To 19
a = Picture1.Width / 20
Picture1.PaintPicture Picture2(Bob(X + 1, Y + 1)).Picture, X * a, Y * a, a, a
Next
Next
So, when you click on the picturebox1, it creates a grid of 20 by 20 of picture2(0). When you click on any one, it randomizes between picture2(0) or picture2(1).
Now, have fun translating that gibberish into vb.net gibberish.
chillah
Robert Hoath
Stevejh
:/
nikonek
Bob(20,20) as Integer
that would keep track of the colours, and I would paint the colours onto the picturebox. But that wont work on vb.net... Sorry again
pcoelho
I want to make a small grid (20x20 is GREAT) which users can paint by clicking squares (or dragging to paint multiple areas). I have no idea how to approach this problem, so i just went for the most straightfoward way i could think of.
I'm using VB.NET Express Edition BETA 2 in case you need to know.
Robert Hoath