我在以下行中收到错误:
索引超出范围异常 - 索引超出范围。必须是非 负数且小于集合的大小
UltraGridColumn col = grid.DisplayLayout.ColScrollRegions[0].VisibleHeaders[0].Header.Column;
答案 0 :(得分:0)
可见标头集合更可能抛出索引超出范围的异常。如果不在视图范围内,您将无法获得任何列标题。
private void Form1_Load(object sender, EventArgs e)
{
// In case you don't have any initialized column
UltraGridColumn column = this.ultraGrid1.DisplayLayout.Bands[0].Columns.Add();
if (!column.IsVisibleInLayout)
{
// In order to scroll to particular column, if it is not in view
this.ultraGrid1.DisplayLayout.ColScrollRegions[0].ScrollColIntoView(column);
}
UltraGridColumn visibleColumn = this.ultraGrid1.DisplayLayout.ColScrollRegions[0].VisibleHeaders[0].Header.Column;
}