Exemplo n.º 1
0
        /// <summary>
        /// 删除数据项
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btDeletItem_Click(object sender, EventArgs e)
        {
            if (null == _cfg)
            {
                return;
            }
            TabPage currTP = tabControlCF1.SelectedTab;

            if (null == currTP)
            {
                return;
            }
            string category = currTP.Text;

            string[] itemNames = _cfg.ItemNamesInTag(category);
            if (null == itemNames || 0 == itemNames.Length)
            {
                MessageBox.Show("没有可供删除的数据项");
                return;
            }
            FormSelectStrings fm = new FormSelectStrings();

            fm.Text = "选择待删除项";
            fm.SetSelectStrings(itemNames);
            if (DialogResult.OK == fm.ShowDialog())
            {
                string[] delItems = fm.GetSelectedStrings();
                if (DialogResult.OK == MessageBox.Show("确定要删除以下数据项?\n" + string.Join("\n", itemNames), "删除警告", MessageBoxButtons.OKCancel))
                {
                    foreach (string delItem in delItems)
                    {
                        _cfg.RemoveItem(delItem);
                    }
                }
                _cfg.Save();
                UpdateCurrPage(true);
            }
        }