0
我的datagrid視圖包含從MySQL數據庫導入的數據行。我需要做的是從datagrid視圖中將所選行的數據加載到按鈕單擊事件上的單獨表單中。如何將數據從datagrid視圖加載到按鈕單擊事件上的單獨窗口窗體?
This is the screenshot of my system
我已經通過使更新書名形式的文本框修飾符公共,寫這個編碼而實現這一點。
private void btn_update_Click(object sender, EventArgs e)
{
Update_Book_Title form = new Update_Book_Title();
form.txt_booknumber.Text = this.datagrid_booktitles.CurrentRow.Cells[1].Value.ToString();
form.txt_isbn.Text = this.datagrid_booktitles.CurrentRow.Cells[2].Value.ToString();
form.txt_author.Text = this.datagrid_booktitles.CurrentRow.Cells[3].Value.ToString();
form.txt_booktitle.Text = this.datagrid_booktitles.CurrentRow.Cells[4].Value.ToString();
form.txt_publishedyear.Text = this.datagrid_booktitles.CurrentRow.Cells[5].Value.ToString();
form.txt_publisher.Text = this.datagrid_booktitles.CurrentRow.Cells[6].Value.ToString();
form.txt_category.Text = this.datagrid_booktitles.CurrentRow.Cells[7].Value.ToString();
form.arrived_date.Text = this.datagrid_booktitles.CurrentRow.Cells[8].Value.ToString();
form.txt_price.Text = this.datagrid_booktitles.CurrentRow.Cells[9].Value.ToString();
form.txt_quantity.Text = this.datagrid_booktitles.CurrentRow.Cells[10].Value.ToString();
form.StartPosition = FormStartPosition.CenterScreen;
form.MdiParent = this.MdiParent;
form.Show();
}
我知道這是不是我們的最佳解決方案,是否有這樣做的任何選擇,這樣我可以從我的數據網格視圖數據加載到更新書名窗戶上的更新按鈕單擊事件形成的?