先上图:
操作方法:
1、先设置一下gridview中属性:IndicatorWidth,一般为:40。如下图;(一般可以显示5位数字。如要更长显示,自己测试一下。)
2、找到gridview中的:CustomDrawRowIndicator事件,输入如下面代码:
1 private void gvMachine_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e) 2 { 3 e.Appearance.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Far; 4 if (e.Info.IsRowIndicator) 5 { 6 if (e.RowHandle >= 0) 7 { 8 e.Info.DisplayText = (e.RowHandle + 1).ToString(); 9 } 10 else if (e.RowHandle < 0 && e.RowHandle > -1000) 11 { 12 e.Info.Appearance.BackColor = System.Drawing.Color.AntiqueWhite; 13 e.Info.DisplayText = "G" + e.RowHandle.ToString(); 14 } 15 } 16 }