DevExpress Gridcontrol显示序号列,用 gridView1_CustomDrawRowIndicator 的事件来实现。具体代码如下:
#region gridView1_CustomDrawRowIndicator /// <summary> /// 显示序号。 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> 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(); } } #endregion
序号列的宽度设置gridView 的IndicatorWidth属性即可。