C#DataGridView未显示滚动条
我在C#中的Windows表单应用程序中进行了DataGridView。但是,当我记录的值超过9或10时。滚动条没有出现,应用程序冻结并且没有响应。我在Windows 10中测试了该应用程序正常工作,但在Windows XP中有此问题。我搜索了很多问题,但是解决方案无法解决我的问题。 我用于DataGridView的代码:
dataGridView1.Invoke((MethodInvoker)(() => dataGridView1.Visible = true));
table.Rows.Add(dataGridView1.Rows.Count + 1, thicness.Text, "FAIL");
dataGridView1.Invoke((MethodInvoker)(() => dataGridView1.Refresh()));
if (dataGridView1.Rows.Count > 1)
{
if (dataGridView1.ScrollBars == ScrollBars.Both)
{
dataGridView1.Invoke((MethodInvoker)(() => dataGridView1.ScrollBars = ScrollBars.Vertical));
}
else if (dataGridView1.ScrollBars == ScrollBars.Vertical)
{
dataGridView1.Invoke((MethodInvoker)(() => dataGridView1.ScrollBars = ScrollBars.Both));
}
dataGridView1.Invoke((MethodInvoker)(() => dataGridView1.Refresh()));
}
dataGridView1.Invoke((MethodInvoker)(() => dataGridView1.Refresh()));
因为我在另一个函数中调用该功能。因此,我需要使用Invoke,但这似乎会影响DataGridView。然后,我尝试在新值进入时尝试更改滚动条的属性。它仅在Windows 10上起作用,而在Windows XP上不起作用。 我在驱动器中显示了应用程序冻结图片,因为由于我是新的stackoverflow,因此我不允许在问题中发布图片。
有人知道如何解决这个问题吗?
I had made a datagridview inside my windows form application in C#. However when the value I recorded exceed 9 or 10. The scrollbars is not appearing and the application freeze and not responding. I tested the application in Windows 10 is working fine but in Windows XP have this issue. I search alot same issue question but the solution couldn't solve my problem.
The code I use for datagridview:
dataGridView1.Invoke((MethodInvoker)(() => dataGridView1.Visible = true));
table.Rows.Add(dataGridView1.Rows.Count + 1, thicness.Text, "FAIL");
dataGridView1.Invoke((MethodInvoker)(() => dataGridView1.Refresh()));
if (dataGridView1.Rows.Count > 1)
{
if (dataGridView1.ScrollBars == ScrollBars.Both)
{
dataGridView1.Invoke((MethodInvoker)(() => dataGridView1.ScrollBars = ScrollBars.Vertical));
}
else if (dataGridView1.ScrollBars == ScrollBars.Vertical)
{
dataGridView1.Invoke((MethodInvoker)(() => dataGridView1.ScrollBars = ScrollBars.Both));
}
dataGridView1.Invoke((MethodInvoker)(() => dataGridView1.Refresh()));
}
dataGridView1.Invoke((MethodInvoker)(() => dataGridView1.Refresh()));
Because I calling the function inside another function. Therefore, I need to use Invoke but this seem effecting the datagridview. Then I try to change the properties of the scrollbars whenever new value come in. It only works on Windows 10 but not the Windows XP.
I show the application freeze picture in drive because I am not allow to post picture in the question due to I am new in stackoverflow.
https://drive.google.com/file/d/1HXCjLwDKDMhUvbOqlp0WIel-w9JrBmyy/view?usp=sharing
Anyone know how to solve this problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论