示例#1
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == dataGridView1.Columns["colEdit"].Index)
            {
                //clicked the edit column.
                var bar = dataGridView1.Rows[e.RowIndex].DataBoundItem as Bar;

                var dlg = new BarEditor()
                {
                    Database = Database, selectedBar = bar
                };
                dlg.ShowDialog();
                RefreshGrid();
            }
            else if (e.ColumnIndex == dataGridView1.Columns["colDelete"].Index)
            {
                //clicked the delete column.
                var bar    = dataGridView1.Rows[e.RowIndex].DataBoundItem as Bar;
                var result = MessageBox.Show(owner: this, text: "Are you sure you want to delete? This cannot be undone.", caption: "Delete", buttons: MessageBoxButtons.OKCancel, icon: MessageBoxIcon.Warning);

                if (result == DialogResult.OK)
                {
                    Database.deleteBar(bar);

                    RefreshGrid();
                }
            }
        }
示例#2
0
        private void miBarAdd_Click(object sender, EventArgs e)
        {
            var dlg = new BarEditor()
            {
                Database = _database
            };

            dlg.ShowDialog(this);
        }
示例#3
0
        private void miNewBar_Click(object sender, EventArgs e)
        {
            var dlg = new BarEditor()
            {
                Database = Database
            };

            dlg.ShowDialog(this);

            RefreshGrid();
        }
示例#4
0
        private void dataGridView1_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            var bar = dataGridView1.Rows[e.RowIndex].DataBoundItem as Bar;

            var dlg = new BarEditor()
            {
                Database = Database, selectedBar = bar
            };

            dlg.ShowDialog();
            RefreshGrid();
        }