GGC 7.403.0.20 - How to get correct instance of GridTableCellStyleInfo?

Event gridGroupingControl_TableControlPrepareViewStyleInfo sets cell style tag to "Error". Function IsErrorInSpreadsheet() wants to access style tag "Error" but GridTableCellStyleInfo is never set to "Error". How can I get correct instance of GridTablecellStyleInfo with "Error"?

=======
Code -

private bool IsErrorInSpreadsheet()
{
GridTableCellStyleInfo serialStyle = gridGroupingControl.Table.GetTableCellStyle(record, "column1");

string serialStyleTag = serialStyle.Tag as string;

// Want to access syle tag in following fucntion
// This never has "Error" tag
if (!string.IsNullOrEmpty(serialStyleTag) && serialStyleTag.Equals("Error"))
{
return true;
}

return false;
}



// Function sets style tag as Error
private void gridGroupingControl_TableControlPrepareViewStyleInfo(object sender, GridTableControlPrepareViewStyleInfoEventArgs e)
{
GridTableCellStyleInfo style = (GridTableCellStyleInfo)e.Inner.Style;

if (style.TableCellIdentity.DisplayElement.Kind == DisplayElementKind.Record && e.Inner.ColIndex == 1)
{
Record record = style.TableCellIdentity.DisplayElement.ParentRecord;
string col1= record.GetValue("column1").ToString();
if (col1.Equals("0"))
{
style.CellTipText = "Invalid column1";
style.Tag = "Error";
}
else
{
style.Tag = "";
}
}
}



Thank you,
Bina Thakkar

3 Replies

JJ Jisha Joy Syncfusion Team April 8, 2010 09:01 AM UTC

Hi Bina Thakkar,

Thank you for using Syncfusion products.

You need to handle QueryCellStyleInfo event, instead of TableControlPrepareViewStyleInfo to set the tag for the cells. See the code:

void gridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)
{
GridTableCellStyleInfo style = (GridTableCellStyleInfo)e.Style;

if (style.TableCellIdentity.DisplayElement.Kind == DisplayElementKind.Record && e.TableCellIdentity.ColIndex == 1)
{
Record record = style.TableCellIdentity.DisplayElement.ParentRecord;
string col1 = record.GetValue("column1").ToString();
if (col1.Equals("0"))
{
style.CellTipText = "Invalid column1";
style.Tag = "Error";
}
else
{
style.Tag = "";
}
}
}

Regards,

Jisha


BT Bina Thakkar April 8, 2010 05:42 PM UTC

Thank you - it worked


JJ Jisha Joy Syncfusion Team April 9, 2010 09:35 AM UTC



Thank you for your update.


Loader.
Up arrow icon