mehdi4467
جمعه 27 فروردین 1389, 17:43 عصر
سلام
من با استقاده از DataGrid این کار رو انجام دادم که زمانی که با موس یک سطر انتخاب شد و بر روی دکمه ویرایش کلیک کردیم اطلاعات اون سطر وارد TextBox های مربوطه میشه. این کاز رو با کد زیر انجام دادم:
firstNameTextBox.Text = Convert.ToString(dataGrid1[dataGrid1.CurrentRowIndex, 1]);
lastNameTextBox.Text = Convert.ToString(dataGrid1[dataGrid1.CurrentRowIndex, 2]);
حالا می خواهم بجای DataGrid از DataGridView استقاده کنم که کد بالا جواب نمیده که اون رو یک تغییر کوچک دادم به این صورت:
firstNameTextBox.Text = Convert.ToString(dataGridView1[dataGridView1.CurrentRow.Index, 1]);
f4.lastNameTextBox.Text = Convert.ToString(dataGridView1[dataGridView1.CurrentRow.Index, 2]);
یعنی یک . بین dataGridView و Index گذاشتم که کار کرد ولی خروجی مثلا سطر اول یه صورت زیر شد:
DataGridViewTextBoxCell { ColumnIndex=6, RowIndex=1 }
لطفا راهنمایی کنید.
من با استقاده از DataGrid این کار رو انجام دادم که زمانی که با موس یک سطر انتخاب شد و بر روی دکمه ویرایش کلیک کردیم اطلاعات اون سطر وارد TextBox های مربوطه میشه. این کاز رو با کد زیر انجام دادم:
firstNameTextBox.Text = Convert.ToString(dataGrid1[dataGrid1.CurrentRowIndex, 1]);
lastNameTextBox.Text = Convert.ToString(dataGrid1[dataGrid1.CurrentRowIndex, 2]);
حالا می خواهم بجای DataGrid از DataGridView استقاده کنم که کد بالا جواب نمیده که اون رو یک تغییر کوچک دادم به این صورت:
firstNameTextBox.Text = Convert.ToString(dataGridView1[dataGridView1.CurrentRow.Index, 1]);
f4.lastNameTextBox.Text = Convert.ToString(dataGridView1[dataGridView1.CurrentRow.Index, 2]);
یعنی یک . بین dataGridView و Index گذاشتم که کار کرد ولی خروجی مثلا سطر اول یه صورت زیر شد:
DataGridViewTextBoxCell { ColumnIndex=6, RowIndex=1 }
لطفا راهنمایی کنید.