mardi 8 août 2017

DataGridView checkbox event > change color of button and drawline

I would like to change the color of a button and a drawline by clicking a checkbox inside of a datagridview.

I tried at first to change the color just with a checkbox. You can see this in my first picture.

First try just with a checkbox

The code for this is:

    protected override void OnPaint(PaintEventArgs e)
    {
        base.OnPaint(e);
        Graphics g;

        g = e.Graphics;
        Pen myPen = new Pen(Color.Black);
        myPen.Width = 1;
        myPen.EndCap = System.Drawing.Drawing2D.LineCap.ArrowAnchor;
        g.DrawLine(myPen, 160, 285, 250, 285);
        g.DrawLine(myPen, 400, 285, 490, 285);
    }

    private void checkBox1_CheckedChanged_1(object sender, EventArgs e)
    {
        if (checkBox1.Checked)

            button1.BackColor = Color.Yellow;
        else
            button1.BackColor = Color.Snow;
    }

Now I would like to change for instance the colour of button1 and the the right drawline by clicking the checkbox in column 1 and row 3 like in this picture:

how it should look like after clicking the checkbox in the datagridview

I already have tried this one.

DataGridView checkbox event

Which possibilities do I have for this?

Thank you very much for helping me!




Aucun commentaire:

Enregistrer un commentaire