C# 使用绑定列表时,将空行添加到我的DataGridView中

C# 使用绑定列表时,将空行添加到我的DataGridView中,c#,datagridview,C#,Datagridview,我有一个DataGridView,我可以将测试数据添加到我的数据网格视图中,但是当我想手动输入任何内容时(通过文本框和下拉框),我只会在数据网格视图中添加一个空行 private void button1_Click(object sender, EventArgs e) { _Reptile = new Reptile(); _Reptile.Name = txtName.Text; _Reptile.Country = Convert.

我有一个
DataGridView
,我可以将测试数据添加到我的数据网格视图中,但是当我想手动输入任何内容时(通过文本框和下拉框),我只会在数据网格视图中添加一个空行

private void button1_Click(object sender, EventArgs e)
    {
        _Reptile = new Reptile();
        _Reptile.Name = txtName.Text;
        _Reptile.Country = Convert.ToString(cbxCountry.SelectedItem);
        _Reptile.Province = Convert.ToString(cbxProvince.SelectedItem);
        _Reptile.Town = Convert.ToString(cbxTown.SelectedItem);
        _Reptile.Collector = txtCole.Text;
        _Reptile.Length = Convert.ToInt32(txtLen.Text);
        _Reptile.Coordinates =txtCo.Text;
        _Reptile.Weight = Convert.ToInt32(txtwe.Text);
        _Reptile.Date = Convert.ToString(dtpDate.Value.ToShortDateString());
        _ReptileList.Add(_Reptile);

    }
这是我的代码:这是为了进入手动输入数据的表单

private void button1_Click(object sender, EventArgs e)
{
    frmAddReptile frmAddReptile = new frmAddReptile();

    frmAddReptile.ShowDialog();
    _ReptileList.Add(_Reptile);
}
那么,在那张表格上我有

internal Reptile _Reptile;
private void button1_Click(object sender, EventArgs e)
{
    _Reptile = new Reptile();
    _Reptile.Name = txtName.Text;
    _Reptile.Country = Convert.ToString(cbxCountry.SelectedItem);
    _Reptile.Province = Convert.ToString(cbxProvince.SelectedItem);
    _Reptile.Town = Convert.ToString(cbxTown.SelectedItem);
    _Reptile.Collector = txtCole.Text;
    _Reptile.Length = Convert.ToInt32(txtLen.Text);
    _Reptile.Coordinates =txtCo.Text;
    _Reptile.Weight = Convert.ToInt32(txtwe.Text);
    _Reptile.Date = Convert.ToString(dtpDate.Value.ToShortDateString());

    this.Close();    
}
然后,单击按钮后,只有一个黑行添加到我的数据网格视图中

好的,我现在已经知道,如果我将所有内容添加到它工作的相同窗口表单(添加到数据网格视图)

这就是我现在所拥有的,但我如何才能使它以不同的形式添加数据
它是否与
内部爬行动物\u爬行动物有关

尝试将爬虫设置为frmAddReptile.\u爬虫。如果不起作用,请将_gradive更改为public或get/set属性,而不是internal属性。这应该能解决问题,然后也许有人会告诉你你做错了什么。