0

I have a class in which I override OnPaint for the control Button, and it gives me an error that

Graphics G does not exist in current context

yet I have Graphics G defined.

abstract class ThemeContainer154 : Control
{
   #region " Initialization "
   protected Graphics G;
   protected Bitmap B;

public ThemeContainer154()
{
   SetStyle((ControlStyles)139270, true);

   _ImageSize = Size.Empty;
   Font = new Font("Verdana", 8);

   MeasureBitmap = new Bitmap(1, 1);
   MeasureGraphics = Graphics.FromImage(MeasureBitmap);

   DrawRadialPath = new GraphicsPath();

   InvalidateCustimization();
}

And here is the "Theme":

class NSButton : Control
{
   protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
   {
      G = e.Graphics;
  G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
      G.Clear(BackColor);
  G.SmoothingMode = SmoothingMode.AntiAlias;
   }
}

The errors I get are:

 The name 'G' does not exist in the current context
jszumski
  • 7,430
  • 11
  • 40
  • 53
user1422473
  • 117
  • 1
  • 3
  • 9

1 Answers1

3

The NSButton does not inherit the ThemeContainer154 .

Change

class NSButton : Control

to

class NSButton : ThemeContainer154 
rocky
  • 7,506
  • 3
  • 33
  • 48