当在运行时添加一个带有图表的用户控件(例如,通过单击按钮)时,它会导致图表的背景变为黑色/负片。
当我在表单加载期间添加用户控件时,它没有这个问题。
private void Form1_Load(object sender, EventArgs e)
{
//this one loads fine
testingControl tc = new testingControl();
this.Controls.Add(tc);
tc.Location = new Point(470, 53);
//......
}
private void Button1_Click(object sender, EventArgs e)
{
testingControl tc = new testingControl();
this.Controls.Add(tc);
//tc.Visible = false;
//tc.Visible = true;
tc.Location = new Point(0, 53);
}
我在谷歌上搜索后发现,隐藏它,然后将它重新设置为可见,这有点解决了它,但这似乎有点不太靠谱。
有人知道我能做些什么来解决这个问题吗?
另外,我从'livecharts‘网站上得到了图表中的数据,但无论有没有数据,问题都会发生。这个问题也发生在所有图表上。
发布于 2020-05-08 01:55:03
得到了类似的问题,并做了一些修改来解决它,
只需将图表可见性更改为false
然后更改,使其在表单加载时可见。
private void Form1_Load(object sender, EventArgs e)
{
pieChart1.Visible = true;
....
}
希望这能对你有所帮助!
https://stackoverflow.com/questions/56586321
复制相似问题