an object reference is required for the nonstatic field method or property

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rameshonweb
    New Member
    • Oct 2007
    • 17

    an object reference is required for the nonstatic field method or property

    Iam getting the error
    an object reference is required for the nonstatic field method or property 'System.Windows .Forms.Control. CreateGraphics( )'

    for this part of code

    public static void clear()
    {

    System.Drawing. Graphics objGraphics = null;
    objGraphics = CreateGraphics( );
    objGraphics.Cle ar(System.Drawi ng.SystemColors .Control);
    objGraphics.Dis pose();
    }

    Need help.
    Thanks in advance.
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    You are in your static main class, there is no Control to "CreateGraphics ()" from.

    Comment

    • rameshonweb
      New Member
      • Oct 2007
      • 17

      #3
      Originally posted by Plater
      You are in your static main class, there is no Control to "CreateGraphics ()" from.
      Got it, Thanks.Iam Still a rookie in C#

      Comment

      Working...