Form2 代码
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;namespace winf
{
/// <summary>
/// Form2 的摘要说明。
/// </summary>
public class Form2 : System.Windows.Forms.Form
{
private System.Windows.Forms.RadioButton radioButton1;
private System.Windows.Forms.RadioButton radioButton2;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null; public Form2()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent(); //
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
} private mycs1 r; public Form2(mycs1 r):this()
{
this.r = r;
} /// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
} #region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.radioButton1 = new System.Windows.Forms.RadioButton();
this.radioButton2 = new System.Windows.Forms.RadioButton();
this.SuspendLayout();
// 
// radioButton1
// 
this.radioButton1.Location = new System.Drawing.Point(48, 48);
this.radioButton1.Name = "radioButton1";
this.radioButton1.TabIndex = 0;
this.radioButton1.Text = "radioButton1";
this.radioButton1.CheckedChanged += new System.EventHandler(this.radioButton1_CheckedChanged);
// 
// radioButton2
// 
this.radioButton2.Location = new System.Drawing.Point(48, 88);
this.radioButton2.Name = "radioButton2";
this.radioButton2.TabIndex = 1;
this.radioButton2.Text = "radioButton2";
this.radioButton2.CheckedChanged += new System.EventHandler(this.radioButton2_CheckedChanged);
// 
// Form2
// 
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(224, 222);
this.Controls.Add(this.radioButton2);
this.Controls.Add(this.radioButton1);
this.Name = "Form2";
this.Text = "Form2";
this.Load += new System.EventHandler(this.Form2_Load);
this.ResumeLayout(false); }
#endregion private void Form2_Load(object sender, System.EventArgs e)
{

} private void radioButton1_CheckedChanged(object sender, System.EventArgs e)
{
r.ChangeAddRowkind("One");   //来自form1 的 r 激活ChangeAddRowkind 事件 再传递给委托 回去。
this.Close();
} private void radioButton2_CheckedChanged(object sender, System.EventArgs e)
{
r.ChangeAddRowkind("Two");
this.Close();
}
}
}
mycs1 类
using System;namespace winf
{
/// <summary>
/// mycs1 的摘要说明。
/// </summary>
/// 

public delegate void AddRowKindHandler(string s);//定义委托 public class mycs1
{
public mycs1()
{
//
// TODO: 在此处添加构造函数逻辑
//
} public event  AddRowKindHandler AddRowKind;  //定义事件
public void ChangeAddRowkind(string s) //触发事件
{
if(AddRowKind!= null)
AddRowKind(s);
}
}
}

解决方案 »

  1.   

    焦点问题:        private void menuItem2_Click(object sender, System.EventArgs e)
            {
                button1.Focus();
                mycs1 r = new mycs1();
                r.AddRowKind += new AddRowKindHandler(r_AddRowKind);            Form2 frm = new Form2(r);
                frm.ShowDialog();
            }
      

  2.   

    如果没有button应该如何设置焦点呢?只有菜单和datagrid.
    为什么焦点不能到datagrid呢?谢谢!
      

  3.   

    你点击菜单时,datagrid处于编辑状态,只要能把编辑状态去掉,就OK了,
    datagrid有个EndEdit方法,你看一下,但好像调用比较麻烦。
    所以我就选择了一个折中的办法:)
      

  4.   

    好高深啊.谢谢!
    还有个问题 点击菜单是为了给datagrid添加行,如果去掉编辑状态,添加行的功能还能实现吗?
      

  5.   

    刚才看了endedit 没看懂 ,5555555555555555555555555!