es in one cell usually can achieved by putting them on one
and putting that into the targeted cell.
For the other points, please see my comment and elaborate on your question.
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
, override its
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.
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.
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
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)
You can leave
in place. Put your custom painting code after it.
The key to custom painting is the
parameter. It holds, among others, an instance of
. 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
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
on it. It's a method inherited from
that will tell the OS that the control needs to be re-drawn. Whenever Windows finds it suitable, it will then call OnPaint().