Click here to Skip to main content
15,902,114 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Invoice_Form ivf = new Invoice_Form();

foreach (ListViewItem row in PList.SelectedItems)
{

ivf.dgv_Quotes.Rows.Add(item.Text);
}
Posted

1 solution

1.on form1 of listview PList add following code on transfer button click
DataTable dt = new DataTable();
            for (int i = 0; i < PList.Columns.Count; i++)
            {
                dt.Columns.Add(new DataColumn(PList.Columns[i].Text.ToString() + i.ToString(), typeof(string)));
            }
            foreach (ListViewItem itRow in this.PList.SelectedItems)
            {
                string[] myStringArray = new string[itRow.SubItems.Count];
                for (int i = 0; i < itRow.SubItems.Count; i++)
                {
                    myStringArray[i] = itRow.SubItems[i].Text;
                }
                dt.Rows.Add(myStringArray);
            }
            Invoice_Form ivf = new Invoice_Form();
            ivf.MyDataTable= dt;
            ivf.Show();

2.on secound form of datagridview add one property of type datatable and on form load bind it to datagridview
C#
private void Invoice_Form_Load(object sender, EventArgs e)
       {
           dataGridView1.DataSource = dt1;
           dataGridView1.Refresh();
       }
       DataTable dt1= new DataTable();
       public DataTable MyDataTable
       {
           set
           {
               dt1= value;
           }
       }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900