Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
148297 | Oct 14,2019 01:42 PM UTC | Oct 15,2019 12:37 PM UTC | WinForms | 1 |
![]() |
Tags: SfDataGrid |
private void button1_Click(object sender, EventArgs e)
{
if (this.sfDataGrid.SelectionController.DataGrid.CurrentCell.ColumnIndex != -1 &&this.sfDataGrid.SelectionController.DataGrid.CurrentCell.RowIndex != -1)
{
var rowIndex = this.sfDataGrid.SelectionController.DataGrid.CurrentCell.RowIndex;
var recordIndex = sfDataGrid.TableControl.ResolveToRecordIndex(rowIndex);
var cellValue = DataGridHelper.GetCellValue(this.sfDataGrid, recordIndex, 2);
MessageBox.Show("Value in cell " + cellValue.ToString());
}
}
public static class DataGridHelper
{
public static object GetCellValue(SfDataGrid sfDataGrid, int recordIndex, intcolumnindex)
{
object cellValue = null;
var record1 = sfDataGrid.View.Records.GetItemAt(recordIndex);
var mappingName = sfDataGrid.Columns[columnindex].MappingName;
cellValue = record1.GetType().GetProperty(mappingName).GetValue(record1, null);
if (cellValue != null)
{
return cellValue;
}
return null;
}
} |
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.