gridControl

2019-11-02 09:20发布

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

1条回答
戒情不戒烟
2楼-- · 2019-11-02 09:48

     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}")});
        }
    }
查看更多
登录 后发表回答