如何隐藏(或删除)最后一个空行?

时间:2019-05-05 07:21:52

标签: c# winforms devexpress

将打印空白行,就像您在Gridview中将其选中为黄色一样。 我更改了Gridview的所有属性,但并没有消失。 如何删除该空行?

enter image description here

class Class1
{
    private List<MemberModel> sourceList;

    public MainForm()
    {
        InitializeComponent();

        SetGridControlData(this.sourceList);

        this.gridView.Columns.Clear();

        this.gridView.Columns.Add(GetGridColumn("idColumn"     , "ID"     , "아이디"     , true));
        this.gridView.Columns.Add(GetGridColumn("nameColumn"   , "Name"   , "이름"       , true));

    }

    private GridColumn GetGridColumn(string name, string fieldName, string caption, bool visible)
    { 
        GridColumn column = new GridColumn();

        column.Name      = name;
        column.FieldName = fieldName;
        column.Caption   = caption;
        column.Visible   = visible;

        return column;
    }

    private void SetGridControlData(List<MemberModel> sourceList)
    {
        this.gridControl.DataSource = sourceList;

        this.gridControl.RefreshDataSource();
    }
}

public class MemberModel
{
    public string ID{ get; set; }

    public string Name{ get; set; }
}

1 个答案:

答案 0 :(得分:2)

在DevExpress网格视图中,您可以通过将NewItemRowPosition设置为NewItemRowPosition.None as described here来隐藏新项目行。例如,

this.gridView.GridOptionsView.NewItemRowPosition = NewItemRowPosition.None;