将网格项双击事件附加到DialogResult.OK事件 [英] Attach Grid Item Double Click Event to DialogResult.OK event

查看:119
本文介绍了将网格项双击事件附加到DialogResult.OK事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Controler类中,正在使用ShowDialog()函数打开一个具有DataGridView的form1

From my Controler class am opening a form1 having a DataGridView using ShowDialog() function

frmOrderCodeResult objfrmOrderCodeResult = new frmOrderCodeResult();
DialogResult dr = new DialogResult();

dr = objfrmOrderCodeResult.ShowDialog(frmMain.SingletonReference);
if (dr == DialogResult.OK)
{                                
    OrderCodeModel objOrderCodeModel = new OrderCodeModel();
    Load(objOrderCodeModel);
}
else if (dr == DialogResult.Cancel)
{
     return;
}


form1在DialogResult.OK上附加了一个确定"按钮,在DialogResult.Cancel事件上附加了一个取消"按钮,并具有daga网格

代码运行后,它将打开对话框,并等待对话框的确定"或取消"响应.
我有2个要求
1.如果用户从网格中选择一个项目并单击确定",它将继续在控制器中执行以下代码,如图所示


form1 is having one OK button attached to DialogResult.OK and Cancel button attached to DialogResult.Cancel event and having a daga grid

Once code ran, it will open the dialog and waiting for my OK or Cancel response from dialog.
i have 2 requirements
1. if user select an item from grid and click on ok, it will continue to execute the below code in the controller as shown

dr = objfrmOrderCodeResult.ShowDialog(frmMain.SingletonReference);
if (dr == DialogResult.OK)


. . .
. . .

2.用户可以双击该行,然后我还需要继续从相同的控制器代码执行

所以我需要将datagrid项目双击事件附加到DialogResult.OK并关闭我的对话框.

有人面临类似的要求吗?用代码块等待您的宝贵答复


. . .
. . .

2. user can double click the row, then also i need to continue to execute from the the same controller code

so i need to attach datagrid item double click event to DialogResult.OK and close my dialog.

Anybody faced similar requirement ? waiting for your valuable response with code block

推荐答案


检查此
Hi ,
Check this
dr = objfrmOrderCodeResult.ShowDialog(frmMain.SingletonReference);
          if (dr == DialogResult.OK)
          {
              dataGridView1.DoubleClick += new EventHandler(dataGridView1_DoubleClick);
          }
      

      void dataGridView1_DoubleClick(object sender, EventArgs e)
      {

      }


最好的问候
M.Mitwalli


Best Regards
M.Mitwalli


在datagridview上注册双击事件,并在双击该行时将dialogresult设置为ok,然后关闭表单.

您将在dr.中获得对话框结果.其余的将保持不变.
register double click event on datagridview and on double clicking the row set the dialogresult to ok and close the form.

You will get the dialog result in dr. Rest will remain the same.


这篇关于将网格项双击事件附加到DialogResult.OK事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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