void btnMonitor_Click(object sender, EventArgs e) { ToolStripMenuItem item = (ToolStripMenuItem)sender; string[] ipAndport = item.Tag.ToString().Split('|'); if (ipAndport.Count() == 3) { int port = 0; int.TryParse(ipAndport[1], out port); var client = new SRControl() { Text = ipAndport[2], ip = ipAndport[0], port = port }; client.Show(Application.Panel); } }
private void AddLoad() { for (int i = 0; i < configInfo.SConfigInfoNum; i++) { ConfigInfo config = configInfo.ConfigInfo[i]; var client = new SRControl() { Text = config.SMonitorName, ip = config.Ip, port = config.Port }; //client.Show(Application.Panel); ToolStripMenuItem btnMonitor = new ToolStripMenuItem(); btnMonitor.Text = config.SMonitorName; btnMonitor.DisplayStyle = ToolStripItemDisplayStyle.ImageAndText; btnMonitor.Image = Resources.monitor; btnMonitor.Click += new EventHandler(btnMonitor_Click); btnMonitor.Tag = config.Ip + "|" + config.Port + "|" + config.SMonitorName; Application.MainTool.Items.Insert(i, btnMonitor); } }