首页新闻找找看学习计划

gridControl

0
[已解决问题] 解决于 2019-11-02 10:06

我想问一下在GridControl控件中,给每一行编个号,类似于行号的那种是怎样实现的?
是它本身自带的一个功能还是说要自己设计

夕阳下的你我的主页 夕阳下的你我 | 初学一级 | 园豆:126
提问于:2019-10-31 10:12
< >
分享
最佳答案
0

     private void gv_info_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e)
    {
        if (e.RowHandle >= 0)
        {
            e.Info.DisplayText = (e.RowHandle + 1).ToString();
        }
    }

    private void gv_info_DataSourceChanged(object sender, EventArgs e)
    {
        DevExpress.XtraGrid.Views.Grid.GridView gv = (DevExpress.XtraGrid.Views.Grid.GridView)sender;
        if (gv != null)
        {
            gv.IndicatorWidth = gv.RowCount.ToString().Length * 10;
            if (gv.IndicatorWidth < 30) gv.IndicatorWidth = 30;

            gv.Columns[0].Summary.AddRange(new DevExpress.XtraGrid.GridSummaryItem[] {
        new DevExpress.XtraGrid.GridColumnSummaryItem(DevExpress.Data.SummaryItemType.Count, gv.Columns[0].FieldName, "总行数:{0}")});
        }
    }
奖励园豆:5
BoneMan | 菜鸟二级 |园豆:233 | 2019-11-01 16:55

我才接触C#不到一个月,谢谢

夕阳下的你我 | 园豆:126 (初学一级) | 2019-11-02 10:06

@夕阳下的你我: 加油!

BoneMan | 园豆:233 (菜鸟二级) | 2019-11-02 10:09
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册