private void OnAddAgent(object sender, EventArgs e)
        {
            int         row          = agentGrid.RowsCount;
            VersionCode version      = VersionCode.V1;
            IPEndPoint  agentIP      = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 161);
            string      getCommunity = "public";
            string      setCommunity = "private";
            string      name         = GetUniqueAgentName();

            SNMPAgent     agent          = new SNMPAgent(version, agentIP, getCommunity, setCommunity, name);
            List <string> forbiddenNames = new List <string>();

            for (int i = 1; i < agentGrid.RowsCount; i++)
            {
                forbiddenNames.Add(agentGrid[i, agentGridColName].DisplayText);
            }
            FormProfile fpr = new FormProfile(agent, forbiddenNames);

            if (fpr.ShowDialog() == DialogResult.OK)
            {
                AddAgent(agent);
                agentGrid.Selection.ResetSelection(true);
                agentGrid.Selection.SelectRow(row, true);
            }
        }
        void agentGrid_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            SourceGrid.Grid agentGrid      = (SourceGrid.Grid)sender;
            int []          rows           = agentGrid.Selection.GetSelectionRegion().GetRowsIndex();
            SNMPAgent       agent          = (SNMPAgent)agentGrid[rows[0], agentGridColName].Tag;
            string          oldname        = agent.Name;
            List <string>   forbiddenNames = new List <string>();

            for (int i = 1; i < agentGrid.RowsCount; i++)
            {
                if (i != rows[0])
                {
                    forbiddenNames.Add(agentGrid[i, agentGridColName].DisplayText);
                }
            }
            FormProfile fpr = new FormProfile(agent, forbiddenNames);

            if (fpr.ShowDialog() == DialogResult.OK)
            {
                agentGrid[rows[0], agentGridColName].Value   = agent.Name;
                agentGrid[rows[0], agentGridColActive].Value = agent.AgentActive;
                agentGrid[rows[0], agentGridColAddr].Value   = "IP: " + agent.AgentIP.ToString();
                agentGrid[rows[0], agentGridColPara].Value   = "Version = " + agent.VersionCode.ToString() + ", GetCommunity = " + agent.GetCommunity + ", SetCommunity = " + agent.SetCommunity;
                agentGrid.Invalidate();
            }
            else
            {
                return;
            }
            if (oldname != agent.Name)
            {
                for (int i = 1; i < grid.RowsCount; i++)
                {
                    if (grid[i, gridColAgent].DisplayText == oldname)
                    {
                        (grid[i, gridColName].Tag as SNMPAgent).Name = agent.Name;
                        grid[i, gridColAgent].Value = agent.Name;
                        grid.Invalidate();
                    }
                }
            }
        }