// 修改栏目 private void button_columns_modify_Click(object sender, EventArgs e) { if (this.listView_columns.SelectedItems.Count == 0) { MessageBox.Show(this, "尚未选定要修改的事项"); return; } PrintColumnDlg dlg = new PrintColumnDlg(); MainForm.SetControlFont(dlg, this.Font, false); if (this.ColumnItems != null) { dlg.ColumnItems = this.ColumnItems; } ListViewItem item = this.listView_columns.SelectedItems[0]; dlg.ColumnName = ListViewUtil.GetItemText(item, COLUMN_NAME); // this.listView_columns.SelectedItems[0].Text; dlg.ColumnCaption = ListViewUtil.GetItemText(item, COLUMN_CAPTION); // this.listView_columns.SelectedItems[0].SubItems[1].Text; try { dlg.WidthChars = Convert.ToInt32( ListViewUtil.GetItemText(item, COLUMN_WIDTHCHARS) // this.listView_columns.SelectedItems[0].SubItems[2].Text ); } catch { dlg.WidthChars = -1; } try { dlg.MaxChars = Convert.ToInt32( ListViewUtil.GetItemText(item, COLUMN_MAXCHARS) // this.listView_columns.SelectedItems[0].SubItems[2].Text ); } catch { dlg.MaxChars = -1; } dlg.ColumnEvalue = ListViewUtil.GetItemText(item, COLUMN_EVALUE); dlg.ShowDialog(this); if (dlg.DialogResult != DialogResult.OK) return; // ListViewItem item = this.listView_columns.SelectedItems[0]; #if NO item.Text = dlg.ColumnName; item.SubItems[1].Text = dlg.ColumnCaption; item.SubItems[2].Text = dlg.MaxChars.ToString(); #endif ListViewUtil.ChangeItemText(item, COLUMN_NAME, dlg.ColumnName); ListViewUtil.ChangeItemText(item, COLUMN_CAPTION, dlg.ColumnCaption); ListViewUtil.ChangeItemText(item, COLUMN_WIDTHCHARS, dlg.WidthChars.ToString()); ListViewUtil.ChangeItemText(item, COLUMN_MAXCHARS, dlg.MaxChars.ToString()); ListViewUtil.ChangeItemText(item, COLUMN_EVALUE, dlg.ColumnEvalue); }
// 修改栏目 private void button_columns_modify_Click(object sender, EventArgs e) { if (this.listView_columns.SelectedItems.Count == 0) { MessageBox.Show(this, "尚未选定要修改的事项"); return; } PrintColumnDlg dlg = new PrintColumnDlg(); MainForm.SetControlFont(dlg, this.Font, false); if (this.ColumnItems != null) { dlg.ColumnItems = this.ColumnItems; } ListViewItem item = this.listView_columns.SelectedItems[0]; dlg.ColumnName = ListViewUtil.GetItemText(item, COLUMN_NAME); // this.listView_columns.SelectedItems[0].Text; dlg.ColumnCaption = ListViewUtil.GetItemText(item, COLUMN_CAPTION); // this.listView_columns.SelectedItems[0].SubItems[1].Text; try { dlg.WidthChars = Convert.ToInt32( ListViewUtil.GetItemText(item, COLUMN_WIDTHCHARS) // this.listView_columns.SelectedItems[0].SubItems[2].Text ); } catch { dlg.WidthChars = -1; } try { dlg.MaxChars = Convert.ToInt32( ListViewUtil.GetItemText(item, COLUMN_MAXCHARS) // this.listView_columns.SelectedItems[0].SubItems[2].Text ); } catch { dlg.MaxChars = -1; } dlg.ColumnEvalue = ListViewUtil.GetItemText(item, COLUMN_EVALUE); dlg.ShowDialog(this); if (dlg.DialogResult != DialogResult.OK) { return; } // ListViewItem item = this.listView_columns.SelectedItems[0]; #if NO item.Text = dlg.ColumnName; item.SubItems[1].Text = dlg.ColumnCaption; item.SubItems[2].Text = dlg.MaxChars.ToString(); #endif ListViewUtil.ChangeItemText(item, COLUMN_NAME, dlg.ColumnName); ListViewUtil.ChangeItemText(item, COLUMN_CAPTION, dlg.ColumnCaption); ListViewUtil.ChangeItemText(item, COLUMN_WIDTHCHARS, dlg.WidthChars.ToString()); ListViewUtil.ChangeItemText(item, COLUMN_MAXCHARS, dlg.MaxChars.ToString()); ListViewUtil.ChangeItemText(item, COLUMN_EVALUE, dlg.ColumnEvalue); }
// 新增栏目 private void button_columns_new_Click(object sender, EventArgs e) { PrintColumnDlg dlg = new PrintColumnDlg(); MainForm.SetControlFont(dlg, this.Font, false); if (this.ColumnItems != null) { dlg.ColumnItems = this.ColumnItems; } if (this.MainForm != null) this.MainForm.AppInfo.LinkFormState(dlg, "printorderdlg_formstate"); dlg.ShowDialog(this); if (this.MainForm != null) this.MainForm.AppInfo.UnlinkFormState(dlg); if (dlg.DialogResult != DialogResult.OK) return; // 名称查重 ListViewItem dup = ListViewUtil.FindItem(this.listView_columns, dlg.ColumnName, 0); if (dup != null) { // 让操作者能看见已经存在的行 ListViewUtil.SelectLine(dup, true); dup.EnsureVisible(); DialogResult result = MessageBox.Show(this, "当前已经存在名为 '"+dlg.ColumnName+"' 的栏目。继续新增?", "PrintOptionDlg", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (result == DialogResult.No) return; } ListViewItem item = new ListViewItem(); #if NO item.Text = dlg.ColumnName; item.SubItems.Add(dlg.ColumnCaption); item.SubItems.Add(dlg.MaxChars.ToString()); #endif ListViewUtil.ChangeItemText(item, COLUMN_NAME, dlg.ColumnName); ListViewUtil.ChangeItemText(item, COLUMN_CAPTION, dlg.ColumnCaption); ListViewUtil.ChangeItemText(item, COLUMN_WIDTHCHARS, dlg.WidthChars.ToString()); ListViewUtil.ChangeItemText(item, COLUMN_MAXCHARS, dlg.MaxChars.ToString()); ListViewUtil.ChangeItemText(item, COLUMN_EVALUE, dlg.ColumnEvalue); this.listView_columns.Items.Add(item); // 让操作者能看见新插入的行 ListViewUtil.SelectLine(item, true); item.EnsureVisible(); // 新增事项后,当前已选择事项的上下移动的可能性会有所改变 listView_columns_SelectedIndexChanged(sender, null); }
// 新增栏目 private void button_columns_new_Click(object sender, EventArgs e) { PrintColumnDlg dlg = new PrintColumnDlg(); MainForm.SetControlFont(dlg, this.Font, false); if (this.ColumnItems != null) { dlg.ColumnItems = this.ColumnItems; } if (this.MainForm != null) { this.MainForm.AppInfo.LinkFormState(dlg, "printorderdlg_formstate"); } dlg.ShowDialog(this); if (this.MainForm != null) { this.MainForm.AppInfo.UnlinkFormState(dlg); } if (dlg.DialogResult != DialogResult.OK) { return; } // 名称查重 ListViewItem dup = ListViewUtil.FindItem(this.listView_columns, dlg.ColumnName, 0); if (dup != null) { // 让操作者能看见已经存在的行 ListViewUtil.SelectLine(dup, true); dup.EnsureVisible(); DialogResult result = MessageBox.Show(this, "当前已经存在名为 '" + dlg.ColumnName + "' 的栏目。继续新增?", "PrintOptionDlg", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (result == DialogResult.No) { return; } } ListViewItem item = new ListViewItem(); #if NO item.Text = dlg.ColumnName; item.SubItems.Add(dlg.ColumnCaption); item.SubItems.Add(dlg.MaxChars.ToString()); #endif ListViewUtil.ChangeItemText(item, COLUMN_NAME, dlg.ColumnName); ListViewUtil.ChangeItemText(item, COLUMN_CAPTION, dlg.ColumnCaption); ListViewUtil.ChangeItemText(item, COLUMN_WIDTHCHARS, dlg.WidthChars.ToString()); ListViewUtil.ChangeItemText(item, COLUMN_MAXCHARS, dlg.MaxChars.ToString()); ListViewUtil.ChangeItemText(item, COLUMN_EVALUE, dlg.ColumnEvalue); this.listView_columns.Items.Add(item); // 让操作者能看见新插入的行 ListViewUtil.SelectLine(item, true); item.EnsureVisible(); // 新增事项后,当前已选择事项的上下移动的可能性会有所改变 listView_columns_SelectedIndexChanged(sender, null); }