简体   繁体   English

Windows 10中的DataGridView显示以编程方式将visible设置为false的列

[英]DataGridView in windows 10 shows columns that have visible set to false programatically

I am wondering if anyone has come across an issue with Windows 10 (using the Enterprise edition) in which an application all of a sudden is showing all columns in a standard datagridview even though the columns have visible set to false in the code behind. 我想知道是否有人遇到了Windows 10(使用企业版)的问题,其中应用程序突然在标准datagridview中显示所有列,即使在后面的代码中这些列的可见设置为false。 This application works fine and has been in production now for over a year, and is running on windows 7, 8 and 8.1 without any issues. 该应用程序运行良好,现已投入生产一年以上,并且可以在Windows 7、8和8.1上正常运行。 The moment it was placed on the 10 machine, it worked, but the datagridviews are showing all columns! 将其放置在10台计算机上的那一刻,它开始工作,但是datagridviews显示所有列!

I have set the compatibility to both 7 and 8 but it still has the same behavior. 我已经将兼容性设置为7和8,但是仍然具有相同的行为。

The code has not changed in a year. 该代码一年没有更改。

I have googled for this error and have come up with nothing so far. 我用谷歌搜索了这个错误,到目前为止还没有提出任何建议。

So has anyone else had this issue? 那么其他人有这个问题吗?

The application is using the 4.5 framework and is a windows form application. 该应用程序使用4.5框架,并且是Windows窗体应用程序。

The code is very straight forward for this: 该代码对此非常简单:

dataGridView1.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
dataGridView1.Columns[0].Visible = false;
dataGridView1.Columns[4].Visible = false;

So again, nothing has changed except for the machine being tested on. 因此,除了要测试的机器外,什么都没有改变。

Any ideas? 有任何想法吗?

Thanks! 谢谢!

The following worked for me. 以下对我有用。

  1. Moved the hidden column to the end of the columns list in the designer. 将隐藏的列移至设计器中列列表的末尾。
  2. Programatically setting the datagridview.coulumns[datagridcolumnd.name].visible = false 以编程方式设置datagridview.coulumns [datagridcolumnd.name] .visible = false

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM