Click here to Skip to main content
15,894,405 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi to all experts, i have a big problem here, i want to print data from my datagridview, when i select 1 row.. there is no problem, but when i try to print multiple row, just last selected row apear
here is the code :
JavaScript
private void button4_Click(object sender, EventArgs e)
        {
            ReportDocument report = new ReportDocument();
            report.Load("katalogbarang.rpt");
            if (Kodetxt.Text == "")
            {

            }
            else
            {
                report.RecordSelectionFormula = "{katalog.id}= " + dg1.SelectedRows[0].Cells[9].Value + "";
            }
            PrintReport rpt = new PrintReport();
            rpt.crystalReportViewer1.ReportSource = report;
            rpt.crystalReportViewer1.Refresh();
            rpt.ShowDialog();
        }


this is my little condition

-------------------------------------------
|kodebarang | namabarang | jumlah | harga |
-------------------------------------------
|0121 | kolor | 3 | 2000 |
|0892 | panci | 1 | 10000 |
|9200 | kutang | 2 | 20000 |
|8989 | cangcut | 8 | 2500 |
|7890 | sapu | 1 | 3000 |
-------------------------------------------

when im selecting one row (left click)

|0121 | kolor | 3 | 2000 |

or when i randomly click (in condition i just click one row) there is no problem,
then i chose randomly and more than just one row, but which appear in crystal report only the first i click

i want report in my crystal report are like this

|9200 | kutang | 2 | 20000 |
|0892 | panci | 1 | 10000 |

or

|7890 | sapu | 1 | 3000 |
|0121 | kolor | 3 | 2000 |
|9200 | kutang | 2 | 20000 |

please someone help me... give me some code and tutorial to resolve my prob
thanks in advance
Posted
Updated 8-Aug-15 17:29pm
v4

1 solution

i was waiting for 3 days, but no one could reply for my problem posting

so sad..
 
Share this answer
 
Comments
Richard MacCutchan 9-Aug-15 13:48pm    
Look at your code, you only use the data from SelectedRows[0].Cells[9].Value. What about the other rows that may have been selected?
Member 14633137 14-Feb-20 21:54pm    
So what is your solution?

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