Ejemplo n.º 1
0
        public ItemForm(object obj, ItemFormState state = ItemFormState.Edit)
        {
            InitializeComponent();

            item = (CommandItem)(obj);
            this.textBox1.Text = item.CommandName;
            this.textBox2.Text = item.Description;
            this.textBox3.Text = item.DelayMicroSeconds.ToString();
            this.textBox4.Text = item.Order.ToString();

            if (state == ItemFormState.Edit)
            {
                this.Text = "编辑";
            }
            else if (state == ItemFormState.Add)
            {
                this.Text = "新增";
            }
        }
Ejemplo n.º 2
0
        private void toolStripBtnAdd_Click(object sender, EventArgs e)
        {
            CommandItem cmdItem  = new CommandItem();
            ItemForm    itemForm = new ItemForm(cmdItem, ItemFormState.Add);

            if (itemForm.ShowDialog(this.listView1) == DialogResult.OK)
            {
                ListViewItem lvi = new ListViewItem();

                lvi.Checked = cmdItem.Hex;
                lvi.Text    = cmdItem.Order.ToString();
                lvi.Tag     = cmdItem;

                lvi.SubItems.Add(cmdItem.CommandName);
                lvi.SubItems.Add(cmdItem.Description);
                lvi.SubItems.Add(cmdItem.DelayMicroSeconds.ToString());

                this.listView1.Items.Add(lvi);
            }
        }