简体   繁体   English

C#Devexpress gridcontrol行值到textedit1

[英]C# Devexpress gridcontrol row value to textedit1

When you click on any row of the gridcontrol, the value in second column of the clicked row goes to textedit1. 当您单击gridcontrol的任何行时,被单击行的第二列中的值将变为textedit1。 Please help me my code as follows and i can not achieve 请按如下方式帮助我我的代码,但我无法实现

 private void gridView1_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
    {
        textEdit1.EditValue = (sender as GridView).GetFocusedRowCellValue("subeadi");
    }

Refer: How to dynamically change cell value of a column when another column's cell value changes 参考: 如何在另一列的单元格值更改时动态更改列的单元格值

I suggest that you handle the GridView.CustomRowCellEdit event and assign the RepositoryItemTextEdit to these cells in this event handler. 我建议您处理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;
}

If you are just trying to set a textedit control value on the form then your code is correct. 如果您只是想在表单上设置textedit控件值,那么您的代码是正确的。 It should work but if you are trying to assign this textedit to grid cell edit control then go through documentation - How to: Create a Column and Assign an Editor to It . 它应该可以工作,但是如果您尝试将此textedit分配给网格单元格编辑控件,则请阅读文档- 如何:创建列并为其分配编辑器

References: 参考文献:
How to: Set a Cell Value When Another Column Value is Changed 如何:更改另一个列值时设置单元格值

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM