Hi,
I was writing these codes to display the before any row. For example:
Samia
Alam
Shell
Then when I click on "Shell" its display on textbox "Alam". If I click on "Alam" its display "Samia".
These codes work perfetly using the datagrid. How can I do using Button.
I was writing these codes to display the before any row. For example:
Samia
Alam
Shell
Then when I click on "Shell" its display on textbox "Alam". If I click on "Alam" its display "Samia".
These codes work perfetly using the datagrid. How can I do using Button.
C#:
private void DGVTest_CellClick(object sender, EventArgs e)
{
if (e.RowIndex == 0)
{
lblID.Text = string.empty;
txtName.Text = string.empty;
}
else if (e.RowIndex >= 1)
{
DataGridViewRow row = this.dgvTest.Rows[e.RowIndex - 1];
if (row != null)
{
lblID.Text = row.Cells["id"].Value.ToString();
txtName.Text = row.Cells["name"].Value.ToString();
}
}