本文介绍了DataGridView设置代码中的行高,并禁用手动调整大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的网格中,我有以下代码段禁用用户手动调整大小:

  dgvTruckAvail.AutoSizeRowsMo​​de = DataGridViewAutoSizeRowsMo​​de.AllCells; 

现在我需要在代码中设置列高,它不起作用(请参阅)


$ b $我认为正是这一行代码导致了不规则的问题。然而,现在我需要弄清楚如何


  1. 代码中的大小行


  1. 阻止用户自己调整行大小

任何指针?

解决方案

设置:

  dgvTruckAvail.AutoSizeRowsMo​​de = DataGridViewAutoSizeRowsMo​​de.None; 
dgvTruckAvail.AllowUserToResizeRows = false;

这将禁用行自动调整和手动排大小调整。要设置行高,可以使用 RowTemplate Height 和 MinimumHeight code>。


In my grid I had following line of code which disabled user's manual resizing:

dgvTruckAvail.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells;

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

  1. Size rows in code

and

  1. Prevent user sizing rows themselves

Any pointers?

解决方案

Set:

dgvTruckAvail.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.None;
dgvTruckAvail.AllowUserToResizeRows = false;

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设置代码中的行高,并禁用手动调整大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-16 05:08