Reputation: 2429
I want to get a cell value particular focused row and previous row ?? I tried this code,
object obj1 = gridView1.GetRowCellValue(gridView1.FocusedRowHandle - 1, gridView1.Columns["Each"]);
string str1= obj1.ToString();
textEdit1.Text = str1;
textEdit1.Text = gridView1.SetRowCellValue(gridView1.FocusedRowHandle, gridView1.Columns["Each"]);
but this code works for button but not work here in the RepositoryItemGridLookupEdit_ValueChanged Event or not work in the CustomUnboundDataEvent.
I want to get a cell value of gridview in Edit Value Change Event and then set in textEdit ? Help me.
Upvotes: 0
Views: 4140
Reputation: 3979
At first this: textEdit1.Text = gridView1.SetRowCellValue(gridView1.FocusedRowHandle, gridView1.Columns["Each"]);
makes no sense, because you dont set the value of the TextEdit, just the value of the Cell. SetRowCellValue is void method!
To get the focused row and previous row, you have to handle the gridview.focusedrowchanged event. You can cast the row into value of your datasource and then assign the value to your textedit.
Example:
private void grvUebersicht_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
{
DataRow row = (DataRow)grvUebersicht.GetRow(e.FocusedRowHandle);
DataRow row2 = (DataRow) grvUebersicht.GetRow(e.PrevFocusedRowHandle);
TextEdit textedit = new TextEdit();
textedit.Text = row["MyColumn"].ToString();
}
Further you should think about using IList as DataSource. In my opinion it is more beautiful and modern style. If you need help iam ready to send example ;)
Upvotes: 1