如何为datagridview单元格触发click事件 [英] how to fire click event for datagridview cells

查看:848
本文介绍了如何为datagridview单元格触发click事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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;
                }
        }

推荐答案

先生,您的标题是如何触发点击事件datagridview单元格并且你已经使函数
sir, as your heading say "how to fire click event for datagridview cells" and you have already made the function
private void dataGridView2_Click(object sender, DataGridViewCellEventArgs e)





如果 dataGridView2_Click 未在 clickgridview 的点击事件中触发,则应转到 datagridview的事件 - >检查 dataGridView2_Click 是否写在 Click事件



if still dataGridView2_Click is not firing on click event of datagridview you should go to the Event's of datagridview -> check if "dataGridView2_Click" is written in front of the Click event

之前

这篇关于如何为datagridview单元格触发click事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆