Recently added Toolstrip to my C# Application , and there is error when click on menu item that call the function but when call the function from Windowsform Button it works perfect. following is my function:
 private void ShowAddDocument(object sender, EventArgs e)
    {
            foreach (var rr in this.gridEX1.GetDataRows())
            {
                if (rr.Cells["Select"].Value != null)
                {
                    if (rr.Cells["DocumentNumber"].Value.ToString() != "")
                    {
                        rr.BeginEdit();
                        rr.Cells["Select"].Value = null;
                        rr.EndEdit();
                    }
                    else
                    {
                        this.gridEX1.Tag = "SELECTED";
                    }
                }
            }
and I use following line to connect function and Toolstrip MenuItem Click event :
this.userControl11.IssueDocMenuItem.Click += new System.EventHandler(ShowAddDocument);
but when click on Toolstrip Menu Item it raise an error : "Object Reference not set to instance of an object". but strange part is when I use Windowsform Button and call the function by following code:
    private void button1_Click(object sender, EventArgs e)
    {
        ShowAddDocument(sender, e);
    }
It my code works without any error!!!.
