Loading

DEV GridView显示行号

 

 1 //显示行号
 2  private void gridView1_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e)
 3  {
 4      e.Appearance.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Far;
 5      if (e.Info.IsRowIndicator)
 6      {
 7         if (e.RowHandle >= 0)
 8         {
 9            e.Info.DisplayText = (e.RowHandle + 1).ToString();
10         }
11         else if (e.RowHandle < 0 && e.RowHandle > -1000)
12         {
13            e.Info.Appearance.BackColor = System.Drawing.Color.AntiqueWhite;
14            e.Info.DisplayText = "G" + e.RowHandle.ToString();
15         }
16      }

同时在load函数中加上这么一句:

gridView.IndicatorWidth = 40;

 

posted @ 2020-09-30 11:39  云辰  阅读(264)  评论(0编辑  收藏  举报