mahesh
mahesh

Reputation: 1390

Transfer A Row Or Multiple Row From Listview To DataGridview

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?.

Upvotes: 0

Views: 3777

Answers (1)

Jay Riggs
Jay Riggs

Reputation: 53603

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);
}

Upvotes: 1

Related Questions