1. 让列的宽度自动填充
如果VGridControl的LayoutStyle属性为BandsView或SingleRecordView,那么把VGridControl的OptionsView.AutoScaleBands设为True就OK了;
如果LayoutStyle属性为MultiRecordView,那么就得写代码了,在Form的Load和VGridControl的SizeChanged事件调用下面的方法:
private void RecalcWidth() { int recordWidth = (vGridControl1.Width - vGridControl1.RowHeaderWidth) / dataTable.Rows.Count; if (recordWidth > vGridControl1.RecordMinWidth) { vGridControl1.RecordWidth = recordWidth; vGridControl1.ScrollVisibility = DevExpress.XtraVerticalGrid.ScrollVisibility.Vertical; } else { vGridControl1.ScrollVisibility = DevExpress.XtraVerticalGrid.ScrollVisibility.Auto; } }
2. 改vgridcontrol的cell的时候,如果不按回车或者选中另外的cell,它不更改,也就是vgridcontrol没有失去焦点,所以如果有别的控件有鼠标点击事件,可以先让这个控件获得焦点,这样vgridcontrol绑定的数据源就会更新。
时间: 2024-12-17 17:16:47