我有DataGridView
我可以将测试数据添加到我的数据网格视图中,但是当我想手动输入任何内容时(通过文本框和下拉框),我只是在数据网格中添加了一个空行图
这是我的代码:这是为了进入手动输入数据的表格
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();
}
然后,单击该按钮后,只有一个黑色行添加到我的数据网格视图中。
好的,我现在已经弄清楚我是否将所有内容添加到相同的窗体中它是否正常工作(添加到数据网格视图)
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);
}
这就是我现在所拥有的但是如何让它以不同的形式添加数据
它与internal Reptile _Reptile;
有什么关系?