繁体   English   中英

如何通过行和列索引读取 GridControl 单元格值

[英]How to read GridControl cell value by its row and column index

我正在使用 DevExpress 的 GridControl 以在不同类型的视图中显示数据。 以前当我使用 DataGridView 时,我可以通过

DataGridViewObject.Rows[RowIndex].Cells[ColumnIndex/ColumnName].Value

现在我想用 GridView object 类似地访问 GridControl 中的相同单元格值,但不想在 for 循环中访问这样的行,也不想在单元格单击事件中获得 RowIndex 和 ColumnIndex 因为我需要在我的应用程序的全局区域,以便我可以使用此语法直接获取特定的单元格值。

您可以使用 GridView 的GetRowCellValue 方法,该方法将采用行索引和字段名称或 GridColumn 实例来返回值。

例如:

var cellValue = myGridView.GetRowCellValue(5, "EmployeeName");

也可以看看:

在代码中读取和修改单元格值

您应该使用以下内容:

private void BindData()
        {
            bs = new BindingSource();
            bs.DataSource = _Supplier.Select();
            gcSupplier.DataSource = bs;
            txtCode.DataBindings.Add("Text", bs, colCode.FieldName);
            txtName.DataBindings.Add("Text", bs, colName.FieldName);
            txtAddress.DataBindings.Add("Text", bs, colAddress.FieldName);
            txtNationalCode.DataBindings.Add("Text", bs, colNationalCode.FieldName);
            txtEconomicCode.DataBindings.Add("Text", bs, colEconomicCode.FieldName);
            txtPostalCode.DataBindings.Add("Text", bs, colPostalCode.FieldName);
            txtTelNumber.DataBindings.Add("Text", bs, colTelNumber.FieldName);
            txtFaxNumber.DataBindings.Add("Text", bs, colFaxNumber.FieldName);
            txtMobileNumber.DataBindings.Add("Text", bs, colMobileNumber.FieldName);
            txtEmail.DataBindings.Add("Text", bs, colEmail.FieldName);
            luePersonType.DataBindings.Add("EditValue", bs, colPersonType_Id.FieldName);
            lueState.DataBindings.Add("EditValue", bs, colState_Id.FieldName);
            lueCity.DataBindings.Add("EditValue", bs, colCity_Id.FieldName);
        }

暂无
暂无

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

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