DataGridView 在代码中设置行高并禁用手动调整大小 [英] DataGridView setting Row height in code and disable manual resize
本文介绍了DataGridView 在代码中设置行高并禁用手动调整大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的网格中,我有以下禁用用户手动调整大小的代码行:
In my grid I had following line of code which disabled user's manual resizing:
dgvTruckAvail.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells;
现在我需要在代码中设置列高,但它不起作用(参见 DataGridView 设置行高不起作用)
Now I needed to set column height in code and it didn't work (see DataGridView setting row height doesn't work)
我认为是这行代码导致了非大小调整问题.但是,现在我需要弄清楚如何
I figured that it was this line of code that caused non-sizing issue. However, now I need to figure out how to
- 调整代码中的行大小
和
- 防止用户自行调整行大小
有什么指点吗?
推荐答案
设置:
dgvTruckAvail.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.None;
dgvTruckAvail.AllowUserToResizeRows = false;
这将禁用行自动调整大小和手动调整行大小.要设置行高,您可以使用 RowTemplate
的 Height
和 MinimumHeight
属性.
This will disable row autosizing and manual row resizing. To set the row height you can use the Height
and MinimumHeight
properties of the RowTemplate
.
这篇关于DataGridView 在代码中设置行高并禁用手动调整大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文