S J

S J

  • NA
  • 171
  • 25.5k

PaintEventArgs e showing null reference

Nov 26 2020 5:17 AM
hi
  1. public void Paint(PaintEventArgs e) //here e is showing null reference in class {"Object reference not set to an instance of an object."}//  
  2. {  
  3. //Graphics g = e.Graphics;  
  4. e.Graphics.DrawRectangle(pen1, rect);  
  5. }   
how to avoid this I need to draw a rectangle by using class method but when I call paint method showing null reference exception.
 

Answers (4)