我想创建一个打印按钮,以向 CrystalReportviewer 显示带有一些标签的 datagridview 值
这就是我所做的
我创建了一个 report.rdlc,其中包含一个类的数据集
这就是我向 dgv 展示我的桌子的方式
private void btnSelectAll_Click(object sender, EventArgs e)
{
if (cmbCategory.Text == "Struk")
{
con.Open();
string query = "SELECT DISTINCT idStruk,Quantity,Price FROM Laporan";
SqlDataAdapter SDA = new SqlDataAdapter(query, con);
DataTable dt = new DataTable();
SDA.Fill(dt);
dataGridView2.DataSource = dt;
con.Close();
}
}
这就是我尝试制作一个按钮以将 dgv 显示到 Crystalreportviewer 工具的方式
public class Orders
{
public string idStruk { get; set; }
public int Quantity { get; set; }
public int Price { get; set; }
}
private void btnPrint_Click(object sender, EventArgs e)
{
List<Orders> lst = new List<Orders>();
lst.Clear();
for (int i = 0; i < dataGridView2.Rows.Count - 1; i++)
{
Orders orders = new Orders
{
idStruk = dataGridView2.Rows[i].Cells[0].Value.ToString(),
Quantity = int.Parse(dataGridView2.Rows[i].Cells[1].Value.ToString()),
Price = int.Parse(dataGridView2.Rows[i].Cells[2].Value.ToString()),
};
lst.Add(orders);
}
rs.Name = "DataSet1";
rs.Value = lst;
//then idk what to do next and what else i need to show them in Crystalreportviewer tool
}
}