问题描述
在我的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
推荐答案
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
这篇关于将网格项双击事件附加到DialogResult.OK事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!