|
//Event Subscription
this.gridGroupingControl1.TableControlCurrentCellMoved += GridGroupingControl1_TableControlCurrentCellMoved;
//Event Customization
private void GridGroupingControl1_TableControlCurrentCellMoved(object sender,GridTableControlCurrentCellMovedEventArgs e)
{
int rowIndex = e.TableControl.CurrentCell.RowIndex;
int colIndex = e.TableControl.CurrentCell.ColIndex;
MessageBox.Show("rowIndex = "+ rowIndex+"\n"+"colIndex = "+colIndex+"\n"+
GetRecordValue(rowIndex, colIndex));
}
//To Get the cell value of current record
private string GetRecordValue(int rowIndex, int columnIndex)
{
string cellValue = string.Empty;
//To get the style of current cell
GridTableCellStyleInfo style = this.gridGroupingControl1.TableControl.GetTableViewStyleInfo(rowIndex, columnIndex);
if (style.TableCellIdentity != null && (style.TableCellIdentity.TableCellType == GridTableCellType.RecordFieldCell
|| style.TableCellIdentity.TableCellType == GridTableCellType.AlternateRecordFieldCell))
{
Record record = style.TableCellIdentity.DisplayElement.GetRecord();
//To get the cell value of current cell
cellValue = record.GetValue(style.TableCellIdentity.Column.Name).ToString();
}
return cellValue;
} |