![](/img/trans.png)
[英]C# How to read all the data in a datagridview and put it in a listbox?
[英]How to return the data of datagridview to listbox? c#
我试图让我在datagridview的订单值和返回的数据等这样
这是保存到列表框到datagridview的代码。
SaveCmd.Parameters.AddWithValue("@Orders", String.Join(", ", listBox1.Items.OfType<string>().ToArray()));
这是从datagridview listBox1.Items.Add(dataGridView1.CurrentRow.Cells[8].Value.ToString());
在列表框中预览的代码listBox1.Items.Add(dataGridView1.CurrentRow.Cells[8].Value.ToString());
它最终会显示类似这样的xD
请帮助,在此先感谢!
尝试使用此方法预览dataGridView1.CurrentRow.Cells[8].Value
到listBox1
每个项目
dataGridView1.CurrentRow.Cells[8].Value.ToString().Split(',').ToList().ForEach(r => listBox1.Items.Add(r.Trim()));
要么
listBox1.DataSource = dataGridView1.CurrentRow.Cells[8].Value.ToString().Split(',').ToList()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.