当您单击gridcontrol的任何行时,单击行的第二列中的值将转到textedit1。请帮我解决我的代码如下,我无法实现
private void gridView1_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
{
textEdit1.EditValue = (sender as GridView).GetFocusedRowCellValue("subeadi");
}
答案 0 :(得分:0)
参考:How to dynamically change cell value of a column when another column's cell value changes
我建议您处理GridView.CustomRowCellEdit事件并将RepositoryItemTextEdit分配给此事件处理程序中的这些单元格。
private void repositoryItemLookUpEdit1_EditValueChanged(object sender, EventArgs e) {
gridView1.SetRowCellValue(gridView1.FocusedRowHandle, "Check", DBNull.Value);
}
private void gridView1_CustomRowCellEdit(object sender, DevExpress.XtraGrid.Views.Grid.CustomRowCellEditEventArgs e) {
if (e.Column.FieldName == "Check" && e.CellValue == DBNull.Value)
e.RepositoryItem = repositoryItemTextEdit1;
}
如果您只是想在表单上设置textedit控件值,那么您的代码是正确的。它应该可以工作但是如果你试图将这个textedit分配给网格单元格编辑控件,那么请浏览文档 - How to: Create a Column and Assign an Editor to It。
参考文献:
How to: Set a Cell Value When Another Column Value is Changed