Formating GroupCaptionCell

Syncfusion 6.1
VS 2005

I'm grouping by 3 columns, one is a string, another a date and another a number. I want to format the groupcaptioncells based on the type of data being displayed. For instance I want the date in the groupcaptioncell to be displayed in a certain format, same with number. Can this be done without using the QuerycellStyleInfo event and checking the value?


6 Replies

JJ Jisha Joy Syncfusion Team June 20, 2008 07:35 AM UTC

Hi Shek,

This can be achieved by using GroupByOptions.CaptionText property. Please refer the code:


gridGroupingControl1.TableDescriptor.Columns["StringColumn"].GroupByOptions.CaptionText = "MyName";



Please try this and let me know if this helps.

Regards,
Jisha



AS Abhishek Shivalingaiah June 24, 2008 07:34 PM UTC

Jisha...I'm not sure I understand the soltuion you proposed. I'm trying to set the formatting on the groupcaptioncells, not the caption text.

Thanks

>Hi Shek,

This can be achieved by using GroupByOptions.CaptionText property. Please refer the code:


gridGroupingControl1.TableDescriptor.Columns["StringColumn"].GroupByOptions.CaptionText = "MyName";



Please try this and let me know if this helps.

Regards,
Jisha





JJ Jisha Joy Syncfusion Team June 25, 2008 11:27 AM UTC

Hi Shek,

Thank you for your update.

You can use Format property of GroupByAppearance.GroupCaptionCell to format the GroupCaptionCell.

Please refer the code:



this.gridGroupingControl1.TableDescriptor.Columns["Col3"].GroupByOptions.CaptionText = "{Category}";
this.gridGroupingControl1.TableDescriptor.Columns["Col3"].GroupByAppearance.GroupCaptionCell.Format = "MMM";
this.gridGroupingControl1.TableDescriptor.Columns["Col3"].GroupByAppearance.GroupCaptionCell.CellValueType = typeof(System.DateTime);




Regards,
Jisha



AS Abhishek Shivalingaiah June 27, 2008 01:51 PM UTC

Jisha..thanks for the response. I used the code piece you suggested, but still can't seem to format the date values in the groupcaptioncell. Attached is a sample.
Thanks



>Hi Shek,

Thank you for your update.

You can use Format property of GroupByAppearance.GroupCaptionCell to format the GroupCaptionCell.

Please refer the code:



this.gridGroupingControl1.TableDescriptor.Columns["Col3"].GroupByOptions.CaptionText = "{Category}";
this.gridGroupingControl1.TableDescriptor.Columns["Col3"].GroupByAppearance.GroupCaptionCell.Format = "MMM";
this.gridGroupingControl1.TableDescriptor.Columns["Col3"].GroupByAppearance.GroupCaptionCell.CellValueType = typeof(System.DateTime);




Regards,
Jisha





DateGridGroupingTest_704d8739.zip


AS Abhishek Shivalingaiah July 2, 2008 11:01 PM UTC

Any word on this? Appreciate a response. Thanks

>Jisha..thanks for the response. I used the code piece you suggested, but still can't seem to format the date values in the groupcaptioncell. Attached is a sample.
Thanks



>Hi Shek,

Thank you for your update.

You can use Format property of GroupByAppearance.GroupCaptionCell to format the GroupCaptionCell.

Please refer the code:



this.gridGroupingControl1.TableDescriptor.Columns["Col3"].GroupByOptions.CaptionText = "{Category}";
this.gridGroupingControl1.TableDescriptor.Columns["Col3"].GroupByAppearance.GroupCaptionCell.Format = "MMM";
this.gridGroupingControl1.TableDescriptor.Columns["Col3"].GroupByAppearance.GroupCaptionCell.CellValueType = typeof(System.DateTime);




Regards,
Jisha





DateGridGroupingTest_704d8739.zip



JJ Jisha Joy Syncfusion Team July 4, 2008 06:18 AM UTC

Hi Shek,


Sorry for the delay in getting back to the issue.


You can handle the QueryCellStyleInfo event to solve this. See the below code snippet for more details.



// In form load
this.gridGroupingControl1.TableDescriptor.Columns["Criteria Value"].GroupByOptions.CaptionText = "{Category}";


this.gridGroupingControl1.QueryCellStyleInfo += new Syncfusion.Windows.Forms.Grid.Grouping.GridTableCellStyleInfoEventHandler(gridGroupingControl1_QueryCellStyleInfo);


void gridGroupingControl1_QueryCellStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableCellStyleInfoEventArgs e)
{
if (e.TableCellIdentity.TableCellType == GridTableCellType.GroupCaptionCell)
{
GridCaptionRow gcr = e.TableCellIdentity.DisplayElement as GridCaptionRow;


if (gcr.ParentGroup != null && gcr.ParentGroup.Category != null && gcr.ParentGroup.Name == "Criteria Value")
{
e.Style.CellValueType = typeof(System.DateTime);
e.Style.Format = "dd MM yyyy";
e.Style.Text = string.Format("{0}", e.Style.CellValue);
}
}
}



Regards,
Jisha


Loader.
Up arrow icon