Two
PictureBox
es in one cell usually can achieved by putting them on one
Panel
and putting that into the targeted cell.
For the other points, please see my comment and elaborate on your question.
[Update]
You can move pictureboxes around in a TableLayoutPanel just by defining the target column and row. For several of them in one cell, though, you will have to implement some logic to place them on a shared panel within the cell.
Since you have to implement custom logic anyway, you can also throw the whole talbe stuff away, derive a custom control from
System.Windows.Forms.Control
, override its
OnPaint()
method and draw every picture wherever you need it at the moment.
This gives you more freedom in picture placement and the ability to move pictures in an animation-ish way.
[/Update]
[Update2]
In Project explorer, you right-click on your project and select "New Class". Call it something meaningful, "PictureBoard.cs", for example.
Visual Studio will create the code file for you and integrate it with your solution.
Change
class PictureBoard
to
public class PictureBoard : System.Windows.Forms.Control
and voilà: you just derived your custom new PictureBoard class from all control's base class: Control.
Now create your
OnPaint()
overload. Start typing
"override" plus a spacebar hit and Intellisense should come up with a list of methods you could possibly want to override. Choose OnPaint().
Visual Studio will create a standard OnPaint() override for you:
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
}
You can leave
base.OnPaint(e);
in place. Put your custom painting code after it.
The key to custom painting is the
PaintEventArgs e
parameter. It holds, among others, an instance of
System.Drawing.Graphics
called
e.Graphics. This is used to draw whatever you need to. Look it up on
MSDN[
^]
First, you will want to use one of the overloads of
DrawRectangle()
,
DrawLine()
and
DrawImage()
.
Build your
OnPaint() method in a way that it can be called at any moment since it is unpredictable when that will be the case.
You need to access your images along with positioning data from OnPaint(). Check all data for availability before using it.
Finally, whenever you want your control to update itself, call
Invalidate()
on it. It's a method inherited from
Control
that will tell the OS that the control needs to be re-drawn. Whenever Windows finds it suitable, it will then call OnPaint().
[/Update2]