【发布时间】:2014-06-16 13:58:17
【问题描述】:
我在 Mysql 中有一个包含 4 列(id、nameofcase、priceone、pricetwo)的表。 我制作了一个带有一列的dataGridView1和带有priceone和pricetwo按钮的两列,我可以看到数据。 问题是,当我按下两个按钮之一时,我得到了我想要的信息。 如何将这些信息放入报告中?
private void Form3_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'lawyerspriceDataSet.lawsuit_under_500' table. You can move, or remove it, as needed.
this.lawsuit_under_500TableAdapter.Fill(this.lawyerspriceDataSet.lawsuit_under_500);
}
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
if (e.ColumnIndex == dataGridView1.Columns["priceoneDataGridViewTextBoxColumn"].Index)
{
//with those 2 lines i am getting the information's that i want
dataGridView1.Rows[row].Cells[col - 1].Value.ToString();
dataGridView1.Rows[row].Cells[col].Value.ToString();
}
else if (e.ColumnIndex == dataGridView1.Columns["pricetwoDataGridViewTextBoxColumn"].Index)
{
dataGridView1.Rows[row].Cells[col - 2].Value.ToString();
dataGridView1.Rows[row].Cells[col].Value.ToString();
}
}
}
private void button1_Click(object sender, EventArgs e)
{
Form4 report = new Form4();
report.Show();
}
有谁知道我是怎么做到的?
【问题讨论】:
-
您似乎知道 DataGridViewCellEventArgs 包含 RowIndex,如何从该行获取数据是个问题?
-
不,我不知道 DataGridViewCellEventArgs。在代码中,我做了一个评论,我在网上找到了它,我用那个 messageBox 对其进行了测试,它可以工作。
标签: c# data-binding datagridview datagrid reportviewer