Beispiel #1
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            var senderGrid = (DataGridView)sender;
            var indexItem  = Convert.ToInt16(senderGrid.Rows[e.RowIndex].Cells[0].Value.ToString());

            if (senderGrid.Columns[e.ColumnIndex] is DataGridViewButtonColumn &&
                e.RowIndex >= 0)
            {
                var but = (DataGridViewButtonColumn)senderGrid.Columns[e.ColumnIndex];
                if (but.Text == "Изменить")
                {
                    question = GetIdApi(indexItem);
                    AddEditForm f = new AddEditForm(question);
                    f.ShowDialog();
                    EditQuestionApi(f.item);
                }

                else
                {
                    DeleteQuestionApi(indexItem);
                }

                var items = GetQuestions();
                dataGridView1.DataSource = items;
            }
        }
Beispiel #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            AddEditForm f = new AddEditForm();

            f.ShowDialog();
            AddQuestionApi(f.item);

            var items = GetQuestions();

            dataGridView1.DataSource = items;
        }