gpt4 book ai didi

c# - 如何在 winform datagridview 中添加数组数据?

转载 作者:太空宇宙 更新时间:2023-11-03 14:29:37 25 4
gpt4 key购买 nike

我从 Biz.Bal.GetPersonelById("1") 生成了 Personel[] 类型的数组,但是如果我想添加 winforms,我这样做如下。有更简单的方法吗?像 GridView.dataSource=myArray 吗?

  private void Form1_Load(object sender, EventArgs e)
{
Form_init();
Model.Personel[] list = new Model.Personel[0];

list = Biz.BAL.GetPersonelByID("1");
dataGridView1.Rows[0].Cells[0].Value = list[0].ID;
dataGridView1.Rows[0].Cells[1].Value = list[0].Ad;
dataGridView1.Rows[0].Cells[2].Value = list[0].SoyAd;
dataGridView1.Rows[0].Cells[3].Value = list[0].Maas;
dataGridView1.Rows[0].Cells[4].Value = list[0].Departman;
}

最佳答案

使用数据绑定(bind):Example here

关于c# - 如何在 winform datagridview 中添加数组数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2956156/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com