0
PanelのGraphicsオブジェクトに、別のクラスの関数のパラメータとして渡してアクセスしようとしていますが、「パラメータが無効です」というエラーが表示されます。
これは私がパネルクラスで使用しているコードです:
別のクラスからGraphicsオブジェクトにアクセスする
Graphics g = contentPan.CreateGraphics();//contentPan is a Panel
RectMaker rect_Maker = new RectMaker();
rect_Maker.Draw(g);
これはRectMakerクラス内に存在する関数である。
public void Draw(Graphics g)
{
try
{
g.FillRectangles(Brushes.White, SmallRect);
g.DrawRectangles(Pens.Black, SmallRect);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
それはGraphicsオブジェクトにアクセスすることが可能です別のクラスのパネルの