开发者

Transfer A Row Or Multiple Row From Listview To DataGridview

开发者 https://www.devze.com 2023-03-19 17:04 出处:网络
Is it possible to transfer a row or multiple rows from listview to datagrdiview?. If yes than provide some code.

Is it possible to transfer a row or multiple rows from listview to datagrdiview?. If yes than provide some code.

Suppose Listview1 having 7 columns and multiple rows where as开发者_开发百科 the datagridview1 also having 7 columns.

If I wants to move a selected rows of listview1 with 7 columns's rows to datagridview than how to do?.


Sure. Assume you have a Winform with a ListView named listView1 and a DataGridView with no columns named dataGridView1 run this:

dataGridView1.Columns.Clear();
dataGridView1.Columns.Add("SelectedItemCol", "Selected Items");
foreach (ListViewItem item in listView1.SelectedItems) {
    dataGridView1.Rows.Add(item.Text);
}
0

精彩评论

暂无评论...
验证码 换一张
取 消