WORK 14 ดึงข้อมูลจาก DataGridView มาแสดงใน TextBox
Code : FormBooks.cs
DataGridView1CellContentDoubleClick :
{
String bookname = dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString();
String author = dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString();
String publishedYear = dataGridView1.Rows[e.RowIndex].Cells[3].Value.ToString();
String shelf = dataGridView1.Rows[e.RowIndex].Cells[4].Value.ToString();
String isbn = dataGridView1.Rows[e.RowIndex].Cells[5].Value.ToString();
this.textBoxBookName.Text = bookname;
this.textBoxAuthor.Text = author;
this.textBoxPublishedYear.Text = publishedYear;
this.textBoxShelf.Text = shelf;
this.textBoxISBN.Text = isbn;
}
String bookname = dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString();
String author = dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString();
String publishedYear = dataGridView1.Rows[e.RowIndex].Cells[3].Value.ToString();
String shelf = dataGridView1.Rows[e.RowIndex].Cells[4].Value.ToString();
String isbn = dataGridView1.Rows[e.RowIndex].Cells[5].Value.ToString();
this.textBoxBookName.Text = bookname;
this.textBoxAuthor.Text = author;
this.textBoxPublishedYear.Text = publishedYear;
this.textBoxShelf.Text = shelf;
this.textBoxISBN.Text = isbn;
}
0 ความคิดเห็น