【发布时间】:2014-02-22 12:24:51
【问题描述】:
事件处理程序代码。
private void dataGridView2_Click(object sender, DataGridViewCellEventArgs e)
{
DataGridViewImageCell cell = (DataGridViewImageCell)
dataGridView2.Rows[e.RowIndex].Cells[e.ColumnIndex];
if (cell.Value=="sewagram express")
{
SqlCommand cm1 = new SqlCommand("select * from sewagram", con);
DataTable dth = new DataTable();
SqlDataAdapter da = new SqlDataAdapter(cm1);
da.Fill(dth);
dataGridView1.DataSource = dth;
}
}
【问题讨论】:
-
我希望在单击单元格时可以使用此代码...请帮助
-
变量
cell是ImageCell,但是,您将cell.Value与string进行比较。这很矛盾。 (ImageCell 将 Image 对象作为值)。 -
先生,我该怎么办?
-
那么我应该写什么代码......?
标签: c# winforms visual-studio-2010 datagridview event-handling