在最左边侧自动添加行号,利用事件CustomDrawRowIndicator。
private void gridView1_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e)
{
if (e.Info.IsRowIndicator && e.RowHandle >= 0)
{
e.Info.DisplayText = (e.RowHandle + 1).ToString();
}
}
gridView1.IndicatorWidth = 50;//设置这列的宽度
gridView1.OptionsView.ShowIndicator = true;//显示最左边一列