private void button2_Click(object sender, EventArgs e) { List <BllUser> newRecievers = new List <BllUser>(); int nodeCount = 0; foreach (TreeNode groupNode in treeView1.Nodes) { foreach (TreeNode userNode in groupNode.Nodes) { if (userNode.Checked) { newRecievers.Add(Users[userNode.Index + nodeCount]); } } nodeCount += groupNode.GetNodeCount(false); } try { IEventCRUD eventCRUD = new EventCRUD(serverInstance.server); eventCRUD.UpdateRecieversAndSendOnEvent(Event, newRecievers); Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }