コード例 #1
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            AddMerchandiseForm upForm = new AddMerchandiseForm();

            upForm.merchandiseBindingSource.DataSource = merchandiseDGVBindingSource;
            upForm.merchandiseBindingSource.Position = merchandiseDGVBindingSource.Position;

            if (upForm.ShowDialog() == DialogResult.OK)
            {
                merchandiseDGVTableAdapter.Update(myDataBaseDataSet.MerchandiseDGV);
                int index = dataGridView1.CurrentRow.Index;
                this.merchandiseDGVTableAdapter.Fill(this.myDataBaseDataSet.MerchandiseDGV);
                dataGridView1.CurrentCell = dataGridView1.Rows[index].Cells[2];
            }
        }
コード例 #2
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            AddMerchandiseForm addForm = new AddMerchandiseForm();
            merchandiseDGVBindingSource.AddNew();

            addForm.merchandiseBindingSource.DataSource = merchandiseDGVBindingSource;
            addForm.merchandiseBindingSource.Position = merchandiseDGVBindingSource.Position;

            if (addForm.ShowDialog() == DialogResult.OK)
            {
                merchandiseDGVTableAdapter.Update(myDataBaseDataSet.MerchandiseDGV);
                this.merchandiseDGVTableAdapter.Fill(this.myDataBaseDataSet.MerchandiseDGV);
                dataGridView1.CurrentCell = dataGridView1.Rows[merchandiseDGVBindingSource.Count - 1].Cells[2];
            }
        }