Pass PaintEventArgs into method

后端 未结 1 1517
暖寄归人
暖寄归人 2021-01-23 19:27

I have the following method in C#:

private string adjustColumnValueLength(String value, int maxLength, PaintEventArgs e)
{
    // Set up our string font
    Syst         


        
相关标签:
1条回答
  • 2021-01-23 19:41

    You should only call that method from a Paint event handler. I guess you have something in your code like:

    private void Control_Paint(object sender, PainEventArgs e) { ... }
    

    You should call your method from there (and nowhere else!):

    private void Control_Paint(object sender, PainEventArgs e)
    {
        adjustColumnValueLength("value", 10, e);
    }
    

    If you don't have that, create a event handler:

    this.Control.Paint += Control_Paint;
    

    Also read: Custom Control Painting and Rendering.

    0 讨论(0)
提交回复
热议问题