none
Help updating a Paint Event from elsewhere in my form RRS feed

  • Question

  • Hi,

    I am attempting to update a paint event:

      public void LblPlayer1Name_Paint(object sender, PaintEventArgs e)
            {
                Font font = new Font("Aku & Kamu", 40);
                Brush brush = new System.Drawing.SolidBrush(System.Drawing.Color.Black);
                e.Graphics.TranslateTransform(110, 35);
                e.Graphics.RotateTransform(357);
                e.Graphics.DrawString(main.txtPlayer1name.Text,font,brush,0,0);
            }

    from another form. I have tried using this.Invalidate(); and this.Refresh(); but those did not work. I ideally want to have the text re-drawn every time i click a button on my first form. Any help is greatly appreciated. Thanks.

    Friday, January 10, 2020 9:21 AM

Answers

  • You need to reference the control you want to paint. You cant use this to refer to another form.

    For example:

       MyPrintForm.Invalidate

    or

       MyPrintForml.Label1.Invalidate

    If that does not help you will need to show more details about the two forms and how you start them etc.

    • Marked as answer by Telemonic Friday, January 10, 2020 7:32 PM
    Friday, January 10, 2020 11:09 AM

All replies


  • Regards Les, Livingston, Scotland

    Friday, January 10, 2020 10:43 AM
  • You need to reference the control you want to paint. You cant use this to refer to another form.

    For example:

       MyPrintForm.Invalidate

    or

       MyPrintForml.Label1.Invalidate

    If that does not help you will need to show more details about the two forms and how you start them etc.

    • Marked as answer by Telemonic Friday, January 10, 2020 7:32 PM
    Friday, January 10, 2020 11:09 AM