Esempio n. 1
0
        private void button_modifyBindingItem_Click(object sender, EventArgs e)
        {
            if (this.listView_recordSyntaxAndEncodingBinding.SelectedItems.Count == 0)
            {
                MessageBox.Show(this, "尚未选定要修改的事项");
                return;
            }

            ListViewItem item = this.listView_recordSyntaxAndEncodingBinding.SelectedItems[0];

            RecordSyntaxAndEncodingBindingItemDlg dlg = new RecordSyntaxAndEncodingBindingItemDlg();

            GuiUtil.SetControlFont(dlg, this.Font);

            dlg.RecordSyntax = item.Text;
            dlg.Encoding     = item.SubItems[1].Text;

            dlg.StartPosition = FormStartPosition.CenterScreen;
            dlg.ShowDialog(this);

            if (dlg.DialogResult != DialogResult.OK)
            {
                return;
            }

            item.Text             = dlg.RecordSyntax;
            item.SubItems[1].Text = dlg.Encoding;
        }
Esempio n. 2
0
        private void button_newBindingItem_Click(object sender, EventArgs e)
        {
            RecordSyntaxAndEncodingBindingItemDlg dlg = new RecordSyntaxAndEncodingBindingItemDlg();

            GuiUtil.SetControlFont(dlg, this.Font);

            dlg.Encoding      = this.comboBox_defaultEncoding.Text; // 引入缺省编码方式值
            dlg.StartPosition = FormStartPosition.CenterScreen;
            dlg.ShowDialog(this);

            if (dlg.DialogResult != DialogResult.OK)
            {
                return;
            }

            // 查重
            string strNewSyntax = ZTargetControl.GetLeftValue(dlg.RecordSyntax);

            for (int i = 0; i < this.listView_recordSyntaxAndEncodingBinding.Items.Count; i++)
            {
                string strExistSyntax = this.listView_recordSyntaxAndEncodingBinding.Items[i].Text;
                strExistSyntax = ZTargetControl.GetLeftValue(strExistSyntax);

                if (strNewSyntax == strExistSyntax)
                {
                    MessageBox.Show(this, "数据格式 '" + strNewSyntax + "' 已经存在(第 " + (i + 1).ToString() + " 行),不能重复加入");
                    return;
                }
            }

            ListViewItem item = new ListViewItem();

            item.Text = dlg.RecordSyntax;
            item.SubItems.Add(dlg.Encoding);

            this.listView_recordSyntaxAndEncodingBinding.Items.Add(item);
        }