2
我有一個名爲CircleSector
,它繪製一個PIChart類。發送繪圖從一個類到一個窗體在C#
如果我從form1
調用類,則無法繪製PIChart。
這裏是我的代碼:
Form1中:
public void button1_Click(object sender, EventArgs e)
{
int textdata = Convert.ToInt32(textBox1.Text);
CS = new CircleSector(textdata, this);
// CS.GetGraphicSector(this);
}
CircleSector:
public CircleSector(int TextData , Form1 D)
{
Pen CirclePen = new Pen(Color.Black);
Rect = new Rectangle(XAxis, YAxis, CircleRadius, CircleRadius);
float temp1 = 0;
SectorCircle = this.CreateGraphics();
PIVal = - 360/TextData;
float temp2 = PIVal;
for (int i = 0; i <= TextData; i++)
{
m_Value = i;
SectorCircle.DrawPie(CirclePen, Rect, 0, temp2);
temp1 = temp2;
temp2 = temp2 - PIVal;
}
// MessageBox.Show("Mouse Pressed");
// return SectorCircle;
}
仍然有問題? – Shell
謝謝。問題出在這個.CreateGraphics() – user3458123
@ user3458123如果你有解決方案,那麼不要忘記接受答案?接受答案有助於理解其他人在這種情況下哪種解決方案最好。 – 2014-03-26 03:13:24