locked
print dynamically generated checkbox selected rows from datagridview to crystal report on another form c# RRS feed

  • Question

  • Hello Experts,

    I have dynamically added checkboxes for each row in datagridview (form1)and i am trying to generate crystal report on a new form (form 2) for only those rows whose checkbox is checked.

    My code on form1 button click is 

    private void btn_Print_Click(object sender, EventArgs e) { //here im trying to insert selected rows in datatable which will be datasource for crystal report DataTable table = new DataTable(); int i = 1; foreach (DataGridViewRow row in dataGridView1.SelectedRows)

    //dataGridView1.SelectedRows[0].Cells["select"].Value) { for (int j = 1; j < dataGridView1.ColumnCount; ++j) { table.Rows[i][j] = row.Cells[j].Value; } ++i; } if (cb_reptype.SelectedItem.ToString() == "Individual") { //here im specifying the path for new form2 string path = table.ToString();//dataGridView1.SelectedRows[1].Cells["table"].Value.ToString(); Form2 f2 = new Form2(path); //ReportDocument crystal = new ReportDocument(); //crystal.Load(dataGridView1.SelectedRows[0].Cells["ReportPath"].Value.ToString()); //pass = crystal; f2.Show(); }

    and my code on form2 is

    public partial class Form2 : Form
        {
            public string source;
            public Form2(string path)
            {
                source = path;
                InitializeComponent();
            }
    
            private void Form2_Load(object sender, EventArgs e)
            {
                this.crystalReportViewer1.ReportSource = source;
            }
        }

    on debugging the program and button click event , new form is opening but it is showing below error.

    I have tried a lot of research on this topic but not upto the mark.

    Kindly reply as soon as possible.. Thanks :) 

    • Moved by Just Karl Friday, August 23, 2013 3:22 PM Looking for the proper forum.
    Thursday, August 22, 2013 9:09 PM

Answers

All replies

  • Hello,

    This forum is for discussions and questions regarding profiles and Microsoft's recognition system on the MSDN and TechNet

    sites. It is not for products/technologies.

    As it's off topic here, I am moving the question to the "Where is the forum for..." forum.

    Karl


    When you see answers and helpful posts, please click Vote As Helpful, Propose As Answer, and/or Mark As Answer



    My Blog: http://unlockpowershell.wordpress.com
    My Book: Windows PowerShell 2.0 Bible
    My E-mail: -join ("6B61726C6D69747363686B65406D742E6E6574"-split"(?<=\G.{2})",19|%{[char][int]"0x$_"})

    Friday, August 23, 2013 3:22 PM
  • Crystal Reports for Visual Studio is discussed on SAP's forums: http://forums.sdn.sap.com/forum.jspa?forumID=313

    If you want general Visual C# support, see the Visual C# Language forum on MSDN.

    Karl


    When you see answers and helpful posts, please click Vote As Helpful, Propose As Answer, and/or Mark As Answer



    My Blog: http://unlockpowershell.wordpress.com
    My Book: Windows PowerShell 2.0 Bible
    My E-mail: -join ("6B61726C6D69747363686B65406D742E6E6574"-split"(?<=\G.{2})",19|%{[char][int]"0x$_"})

    • Proposed as answer by Dave PatrickMVP Saturday, August 24, 2013 2:13 PM
    • Marked as answer by Just Karl Monday, September 2, 2013 4:23 PM
    Friday, August 23, 2013 3:25 PM
  • i understand this is off topic forum , but which forum is the perfect place to post this ?
    Saturday, August 24, 2013 9:01 AM
  • I'd try the two that Karl mentioned.

     

     


    Regards, Dave Patrick ....
    Microsoft Certified Professional
    Microsoft MVP [Windows]

    Disclaimer: This posting is provided "AS IS" with no warranties or guarantees , and confers no rights.

    Saturday, August 24, 2013 2:13 PM