// delete block / data type private void mnuBlockDelete_Click(object sender, EventArgs e) { if (treeView1.SelectedNode.Tag is PlcBlock) { PlcBlock block = (PlcBlock)treeView1.SelectedNode.Tag; DialogResult dlg = MessageBox.Show("Do you really want to delete the block " + block.Name + "?", "Delete block", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dlg == DialogResult.Yes) { block.Delete(); IterateThroughDevices(project); } } if (treeView1.SelectedNode.Tag is PlcStruct) { PlcStruct block = (PlcStruct)treeView1.SelectedNode.Tag; DialogResult dlg = MessageBox.Show("Do you really want to delete the data type " + block.Name + "?", "Delete data type", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dlg == DialogResult.Yes) { block.Delete(); IterateThroughDevices(project); } } }
private void mnuBlockDelete_Click(object sender, EventArgs e) { // delete block / data type if (treeView1.SelectedNode.Tag is PlcBlock) { PlcBlock block = (PlcBlock)treeView1.SelectedNode.Tag; if (MessageYesNo("Do you really want to delete the block " + block.Name + "?", "Delete block") == DialogResult.Yes) { try { block.Delete(); IterateThroughDevices(project); } catch (Exception ex) { MessageError(ex.Message, "Exception"); } } } else if (treeView1.SelectedNode.Tag is PlcStruct) { PlcStruct block = (PlcStruct)treeView1.SelectedNode.Tag; if (MessageYesNo("Do you really want to delete the data type " + block.Name + "?", "Delete data type") == DialogResult.Yes) { try { block.Delete(); IterateThroughDevices(project); } catch (Exception ex) { MessageError(ex.Message, "Exception"); } } } }