Exemple #1
0
        /// <summary>
        /// 点击表格+1按钮列
        /// </summary>
        private void counterView_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            int rowIndex = e.RowIndex;

            if (e.ColumnIndex == columnIncrease.Index && rowIndex > -1)
            {
                if (rowIndex == counterView.Rows.Count - 1)
                {
                    //点击了表格尾行,添加新计数
                    Counter      newCounter = new Counter();
                    DialogEdit   edit       = new DialogEdit(newCounter);
                    DialogResult result     = edit.ShowDialog();
                    if (result == DialogResult.OK)
                    {
                        AddCounter(newCounter);
                    }
                }
                else
                {
                    //点击了计数器的+1
                    var row = counterView.Rows[rowIndex];
                    ((Counter)row.Tag).Increase(true);
                    UpdateRow(row);
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// 点击菜单:编辑
        /// </summary>
        private void menuItemEdit_Click(object sender, EventArgs e)
        {
            var row = GetSelectedRow();

            if (row != null)
            {
                Counter      c      = (Counter)row.Tag;
                DialogEdit   edit   = new DialogEdit(c, "编辑");
                DialogResult result = edit.ShowDialog();
                if (result == DialogResult.OK)
                {
                    UpdateRow(row);
                    ManualCounter.Save();
                }
            }
        }