/// <summary> /// GridView 显示行号 设置行号列的宽度 /// </summary> /// <param name="gv">GridView 控件名称</param> /// <param name="width">行号列的宽度 如果为null或为0 则 默认宽度为30</param> public void DrawRowIndicator(DevExpress.XtraGrid.Views.Grid.GridView gv, int width) { gv.CustomDrawRowIndicator += new DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventHandler((obj, e) => { //最顶上一行显示总行数 //if (e.Info.Kind == DevExpress.Utils.Drawing.IndicatorKind.Header) //{ // e.Info.DisplayText = ((DevExpress.XtraGrid.Views.Grid.GridView)obj).DataRowCount.ToString(); //} if (e.Info.IsRowIndicator && e.RowHandle > -1) { e.Info.DisplayText = (e.RowHandle + 1).ToString(); } }); //if (width != null) //{ if (width != 0) { gv.IndicatorWidth = width; } else { gv.IndicatorWidth = 30; } //} //else //{ // gv.IndicatorWidth = 30; //} }