【问题标题】:Right click on datagridview and call edit form to edit selected row右键单击datagridview并调用编辑表单来编辑选定的行
【发布时间】:2013-04-27 16:38:42
【问题描述】:

我有一个组合框和一个文本框来过滤我的数据并在 datagridview 中显示它们:

    AFDBEntities adbe = new AFDBEntities();

    private void btnSearch_Click(object sender, EventArgs e)
    {

        var cbo = cmbInstallers.Text;
        switch (cbo){
            case "First Name":
                var ianst = (from x in adbe.TblInstallers
                         where x.FirstName.Contains(txtSearch.Text)
                         select x).ToList();
                dgvSearched.DataSource = ianst;
    }

现在当我有例如 4 个包含“x”的结果时,它们都显示在 datagridview 中。 我想在 datagridview 上进行右键单击选项,它为我提供了一个菜单,用于打开新表单以编辑选定的结果行。

Picture of Form

【问题讨论】:

    标签: c# winforms linq datagridview


    【解决方案1】:

    您需要为 DataGridView 分配一个上下文菜单,然后通过 DataGridView 上的 Editing_Control_Showing 事件句柄监视其事件。

    【讨论】:

      猜你喜欢
      • 2012-03-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-25
      • 2015-01-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多