void gridGroupingControl1_SourceListListChangedCompleted(object sender, TableListChangedEventArgs e)
{
//Used to check whether record is modified
if (e.ListChangedType == ListChangedType.ItemChanged)
{
//Used to get the record value from modified record
string recordValue = this.gridGroupingControl1.Table.Records[e.NewIndex].GetValue("Description").ToString();
//Used to check the record value of modified record from particular column(which has custom control)
if (recordValue == "Descnew")
{
int colIndex = 2;//Custom celltype column index
int topRowIndex=this.gridGroupingControl1.TableControl.TopRowIndex;
int leftColIndex=this.gridGroupingControl1.TableControl.LeftColIndex;
//Used to set the custom celltype cellvalue
GridTableCellStyleInfo style = this.gridGroupingControl1.TableControl.GetTableViewStyleInfo(e.NewIndex + topRowIndex, leftColIndex + colIndex);
style.TableCellIdentity.DisplayElement.GetRecord().SetValue("Description","Sample");
//To refresh the data
e.Table.TableDirty = true;
}
}
}
Sample:
http://www.syncfusion.com/downloads/support/forum/119452/ze/Sample_Custom_CellType_Update1025394026
Please let me know if you have any concerns.
Regards,
Neelakandan
protected override void OnDraw(Graphics g, Rectangle clientRectangle, int rowIndex, int colIndex, GridStyleInfo style)
{
try
{
style.Control = control;
//**************************************************************
//you need to set the text for custom cell in this place.
//Because for every time, this event will be called and the text for this cell can be assigned if we set LabelText of that control.
//So that the below way is the possible method to assign the text as default.
//control object is assigned for every cell in this place.
//**************************************************************
if (style.CellIdentity is GridTableCellViewStyleInfoIdentity)
{
GridTableCellViewStyleInfoIdentity id = style.CellIdentity as GridTableCellViewStyleInfoIdentity;
GridControlBase grid = id.GetActiveGridView() as GridControlBase;
if (grid is GridTableControl)
{
control.Update(id.DisplayElement.GetRecord().GetValue("val2").ToString());
}
}
base.OnDraw(g, clientRectangle, rowIndex, colIndex, style);
}
catch (Exception e)
{
Console.WriteLine("ERROR: " + e.Message);
}
}
Modified sample:
http://www.syncfusion.com/downloads/support/forum/119452/ze/Sample_Modified-276232000
Please let me know if you have any concerns.
Regards,
Neelakandan