问题描述
亲爱的所有人,如果有人帮助我解决我的问题,我感激不尽。我在C#windows应用程序中有一个像Export Form这样的表单,还有图片框和DataGridView。我想将图片框和DataGridView行发送到Crystal Report。
实际上,我可以将两个水晶报告和Datagridview中的图片同时传递给另一个Crystal报告。但当我在一个Crystal Report中汇总时,它会向我显示错误。以粗体显示的错误。
如果有人帮助我我会感激。
这是我的代码:
我尝试过:
Dear All, I appreciate if someone helps me to solve my problem. I have a form like Export Form in C# windows application and there are picture box and DataGridView. I want to Send both picture box and DataGridView Rows to Crystal Report.
Actually, I can pass both but picture in one crystal report and Datagridview to another Crystal report. but when I put together in one Crystal Report it shows me the error. The error that shows in bold font.
I appreciate if someone helps me.
Here is my Code:
What I have tried:
//Picture Code
ApplicationDataSet ApplicationInvoiceDataSet = new ApplicationDataSet();
ExportInvoiceCrystal ExportInvoiceInfo = new ExportInvoiceCrystal();
System.IO.MemoryStream SIMS = new System.IO.MemoryStream();
#region Image
ExportInvoiceImage.Image.Save(SIMS, ExportInvoiceImage.Image.RawFormat);
byte[] ExportByte = new byte[0];
ExportByte = SIMS.ToArray();
ApplicationInvoiceDataSet.ImageDataTable.Rows.Add(ExportByte);
ExportInvoiceInfo.SetDataSource(ApplicationInvoiceDataSet.Tables["ImageDataTable"]);
// ========================================================
// DataGridView Code
DataSet DataGridDataSet = new DataSet();
DataTable DataGridDataTable = new DataTable();
DataGridDataTable.Columns.Add("ItemNo", typeof(Int64));
DataGridDataTable.Columns.Add("ItemName", typeof(string));
DataGridDataTable.Columns.Add("ItemQuantity", typeof(Int64));
DataGridDataTable.Columns.Add("ItemPrice", typeof(double));
DataGridDataTable.Columns.Add("ItemTotal", typeof(double));
foreach (DataGridViewRow DataGridRows in DataGridExportItem.Rows)
{
DataGridDataTable.Rows.Add(DataGridRows.Cells[0].Value,
DataGridRows.Cells[1].Value, DataGridRows.Cells[2].Value,
DataGridRows.Cells[3].Value, DataGridRows.Cells[4].Value);
}
DataGridDataSet.Tables.Add(DataGridDataTable);
DataGridDataSet.WriteXmlSchema("ApplicationDataGrid.xml");
ExportInvoiceInfo.SetDataSource(DataGridDataSet);
推荐答案
//Picture Code
//... your code here...
//Note: do not use SetDataSource yet!
//DataGridView Code
//... your code here...
//finally
//ApplicationInvoiceDataSet contains ["ImageDataTable"] already
//add DataGridView data
ApplicationInvoiceDataSet.Tables.Add(DataGridDataTable);
ExportInvoiceInfo.SetDataSource(ApplicationInvoiceDataSet);
详情请见: []
这篇关于将表单上的图像和datagridview传递给水晶报表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!