读书笔记 UltraGrid(4)

控制行高和列宽
缺省使用控件内部设定的行高和列宽,针对整个Grid所有的行和列;
this.ultraGrid.DisplayLayout.Override.DefaultColWidth=-1
this.ultraGrid.DisplayLayout.Override.DefaultRowHeight=-1
那实际的行高和行宽并不是-1,究竟是多少呢?
this.ultraGrid.Rows[0].Height,行高为20
this.ultraGrid.DisplayLayout.Bands[0].Columns[0].Width,列宽为133
也可以使用以下方法:
this.ultraGrid1.Rows[0].Cells[0].Width得到列宽;
this.ultraGrid.Rows[0].Height=30可以改变行所在的band内的所有行的高度,而不影响其它band内的行高!
这样说好像不能让某一行有特殊的高度的。
同理this.ultraGrid.DisplayLayout.Bands[0].Columns[0].Width = 200可改变列宽!
同样是针对Grid中的所有列的。
有疑问:ultraGrid所有band内列宽必须是一样的?
DevExpress这家公司的好像就没这个要求。
注意:
this.ultraGrid1.Rows[0].Cells[0].Width这个属性是只读哦,不能改变列宽哦。

同样如果针对每个band,则可以使用:
 this.ultraGrid1.DisplayLayout.Bands[i].Override.DefaultRowHeight = 30;
 this.ultraGrid1.DisplayLayout.Bands[i].Override.DefaultColWidth  = 100;
这样可以让每个band有不同的行高!
但列宽是一样的,并且是设置为最大的那个。这个有点奇怪。

补充:看来误解ultraGrid了。不是所有的band中的列宽都必须一样的。可以设置的,只是缺省如此。
this.ultraGrid.DisplayLayout.Override.AllowColSizing = AllowColSizing.Free
这样设置后,则列宽可以自由调整了。


 

原文地址:https://www.cnblogs.com/chump/p/2343632.html