How to get gridview cell value in RepositoryItemGridLookupEdit_ValueChanged Event and set in TextEdit?

好久不见. 提交于 2019-12-11 14:13:22

问题


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.


回答1:


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 ;)



来源:https://stackoverflow.com/questions/20214028/how-to-get-gridview-cell-value-in-repositoryitemgridlookupedit-valuechanged-even

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!