简体   繁体   English

DataGridView 在窗体 Windows 10 上不可见

[英]DataGridView not visible on form Windows 10

I had an issue with a DataGridView not being shown on a Form that was initialised from another Form on Windows 10 in Release mode.我遇到了一个问题,即 DataGridView 未显示在从 Windows 10 上的另一个窗体在发布模式下初始化的窗体上。 The issue is not present when debugging code in Debug Mode.在调试模式下调试代码时不存在此问题。 I even tried turning off optimization.我什至尝试关闭优化。 It took me 2 days to work out the issue so im making this with the hope it helps someone else facing this issue as there it NOTHING online for this specific issue.我花了 2 天的时间来解决这个问题,所以我做了这个,希望它能帮助其他人解决这个问题,因为网上没有针对这个特定问题的任何内容。

Scenario (Issue ONLY occurs in this scenario in Release built code)
Form1 - Click button to show Form2
Form2 - Has a DataGridView which is not loaded/shown on the form

If ColumnHeadersHeight is set to anything other than default (21) on FormLoad then the DataGridView will not be shown on the form.如果ColumnHeadersHeight上设置为除默认值 (21) 以外的任何值,则 DataGridView 将不会显示在表单上。

You can change the ColumnHeadersHeight property AFTER the form has loaded.您可以在加载表单后更改ColumnHeadersHeight属性。

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

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