samedi 27 novembre 2021

Randomly put an image in specific places using C#

I am absolutely new with C#, so I hope my question is not completely off.

enter image description here

As you can see in the picture above, I have a form, in which there is a table (image) and a button. In the resources of the project, I have another image (black_rectangle.png), which is a black rectangle, exactly at the same size of each the table's cell. This is what I'm trying to achieve: Each time the 'Again' button is clicked, I want the six black rectangles to cover two of the tree cells in each column, in a random manner. For example, after the first try, the table could look like this: enter image description here

I'm basically stuck at the beginning:

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }

    private void button1_Click(object sender, EventArgs e)
    {
        Random random = new Random();
    }
}



Aucun commentaire:

Enregistrer un commentaire