We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

How to make summary cell editable

Hi,

I want to make summary cell editable and on change of summary cell value...update the lower cell values that has made this summary cell.

can you give me some sample code

7 Replies

AD Administrator Syncfusion Team January 15, 2007 02:20 PM UTC

Here is a link to a forum thread that discusses this topic.

http://www.syncfusion.com/Support/Forums/message.aspx?&MessageID=49541


AD Administrator Syncfusion Team January 15, 2007 03:45 PM UTC

can you please paste the sample code....i am not able to download the sample zip file....


AD Administrator Syncfusion Team January 15, 2007 05:20 PM UTC

Please try downloading again. I was able to download both links in the last post of that thread.

If you still cannot download them, then please submit a Direct Trac support incident and we can try getting them to you through your incident.


AD Administrator Syncfusion Team January 15, 2007 05:26 PM UTC

problem is ,here i dont have access for downloading any file....so please paste code in the reply so i can get that.

Thanks


AD Administrator Syncfusion Team January 15, 2007 07:21 PM UTC

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using Syncfusion.Windows.Forms.Grid;
using Syncfusion.Windows.Forms.Grid.Grouping;
using Syncfusion.Grouping;
using Syncfusion.Diagnostics;

namespace GGC_HideTable
{
///
/// Summary description for Form1.
///

public class Form1 : System.Windows.Forms.Form
{
private Syncfusion.Windows.Forms.Grid.Grouping.GridGroupingControl gridGroupingControl1;
///
/// Required designer variable.
///

private System.ComponentModel.Container components = null;

public Form1()
{
//
// Required for Windows Form Designer support
//

InitializeComponent();

//
// TODO: Add any constructor code after InitializeComponent call
//
}

///
/// Clean up any resources being used.
///

protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///

private void InitializeComponent()
{
this.gridGroupingControl1 = new Syncfusion.Windows.Forms.Grid.Grouping.GridGroupingControl();
((System.ComponentModel.ISupportInitialize)(this.gridGroupingControl1)).BeginInit();
this.SuspendLayout();
//
// gridGroupingControl1
//
this.gridGroupingControl1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.gridGroupingControl1.BackColor = System.Drawing.SystemColors.Window;
this.gridGroupingControl1.Location = new System.Drawing.Point(16, 24);
this.gridGroupingControl1.Name = "gridGroupingControl1";
this.gridGroupingControl1.ShowGroupDropArea = true;
this.gridGroupingControl1.Size = new System.Drawing.Size(576, 424);
this.gridGroupingControl1.TabIndex = 0;
this.gridGroupingControl1.TableDescriptor.AllowNew = false;
this.gridGroupingControl1.Text = "gridGroupingControl1";
this.gridGroupingControl1.VersionInfo = "4.101.0.22";
this.gridGroupingControl1.TableControlCurrentCellEditingComplete += new Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlEventHandler(this.gridGroupingControl1_TableControlCurrentCellEditingComplete);
this.gridGroupingControl1.QueryCellStyleInfo += new Syncfusion.Windows.Forms.Grid.Grouping.GridTableCellStyleInfoEventHandler(this.gridGroupingControl1_QueryCellStyleInfo);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(608, 486);
this.Controls.Add(this.gridGroupingControl1);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
((System.ComponentModel.ISupportInitialize)(this.gridGroupingControl1)).EndInit();
this.ResumeLayout(false);

}
#endregion

///
/// The main entry point for the application.
///

[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private int numberParentRows = 5;
private int numberChildRows = 10;

private DataTable GetParentTable()
{
DataTable dt = new DataTable("ParentTable");


dt.Columns.Add(new DataColumn("parentID",typeof(int))); //lower case p
dt.Columns.Add(new DataColumn("ParentName",typeof(int)));
dt.Columns.Add(new DataColumn("ParentDec",typeof(int)));
dt.Columns.Add(new DataColumn("check", typeof(bool)));

for(int i = 0; i < numberParentRows; ++i)
{
DataRow dr = dt.NewRow();
dr[0] = i;//.ToString();
dr[1] = i;
dr[2] = i*12;
dt.Rows.Add(dr);
}

return dt;
}

private DataTable GetChildTable()
{
DataTable dt = new DataTable("ChildTable");

dt.Columns.Add(new DataColumn("childID")); //lower case c
dt.Columns.Add(new DataColumn("Name"));
dt.Columns.Add(new DataColumn("ParentID")); //upper case P

for(int i = 0; i < numberChildRows; ++i)
{
DataRow dr = dt.NewRow();
dr[0] = i.ToString();
dr[1] = string.Format("ChildName{0}",i);
dr[2] = (i % numberParentRows).ToString();
dt.Rows.Add(dr);
}

return dt;
}

DataSet ds;
private void Form1_Load(object sender, System.EventArgs e)
{
DataTable parentTable = GetParentTable();

this.gridGroupingControl1.DataSource = parentTable;

Console.WriteLine("ParentTable in the dataset is hidden in grid");

GridSummaryColumnDescriptor sd1 = new GridSummaryColumnDescriptor("ParentDec",SummaryType.Int32Aggregate ,"ParentDec","{Sum:####}");
GridSummaryColumnDescriptor sd2 = new GridSummaryColumnDescriptor("ParentName",SummaryType.Int32Aggregate ,"ParentName","{Sum:####}");
//For showing two summary row
this.gridGroupingControl1.TableDescriptor.SummaryRows.Add( new GridSummaryRowDescriptor("Row2", "parentID", new GridSummaryColumnDescriptor[] {sd1}));
this.gridGroupingControl1.TableDescriptor.SummaryRows.Add( new GridSummaryRowDescriptor("Row1", "parentName", new GridSummaryColumnDescriptor[] {sd2}));
this.gridGroupingControl1.TableDescriptor.Appearance.AnySummaryCell.Borders.All = new GridBorder(GridBorderStyle.Standard);

}

private void gridGroupingControl1_QueryCellStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableCellStyleInfoEventArgs e)
{
if(e.TableCellIdentity.TableCellType == GridTableCellType.SummaryFieldCell || e.TableCellIdentity.TableCellType == GridTableCellType.SummaryEmptyCell)
{
#region For edit the Summary Cell...
e.Style.CellType = "TextBox";
e.Style.BackColor = Color.White;

//By default Enable property of GroupCaptionCell to False.
//you need to change the Enabled property to True.
e.Style.Enabled = true;

//By default ReadOnly property of GroupCaptionCell to True.
//you need to change the ReadOnly property to False.
e.Style.ReadOnly = false;
#endregion

#region For display the summary value...

Element el = e.TableCellIdentity.DisplayElement;

if( el.Kind == DisplayElementKind.Summary )
{
GridSummaryRow row = el as GridSummaryRow;
GridSummaryRowDescriptor rd = row.SummaryRowDescriptor;

int index = e.TableCellIdentity.Table.TableDescriptor.ColIndexToField(e.TableCellIdentity.ColIndex);
string ColumnName = e.TableCellIdentity.Table.TableDescriptor.Columns[index].Name;

if(summayrecord.Contains( rd.Name) )
{

Hashtable summaycolumns = summayrecord[rd.Name] as Hashtable ;
if(summaycolumns.Contains( ColumnName))
{
e.Style.Text = summaycolumns[ColumnName].ToString() ;
}
}
}
#endregion
}

}


Hashtable summayrecord = new Hashtable();


private void gridGroupingControl1_TableControlCurrentCellEditingComplete(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlEventArgs e)
{
#region Store the summary value to the hashtable
GridCurrentCell cc = e.TableControl.CurrentCell;
GridTableCellStyleInfo style = cc.Renderer.CurrentStyle as GridTableCellStyleInfo;
Element el = style.TableCellIdentity.DisplayElement;

if( el.Kind == DisplayElementKind.Summary )
{
GridSummaryRow row = el as GridSummaryRow;
GridSummaryRowDescriptor rd = row.SummaryRowDescriptor;

int index = e.TableControl.TableDescriptor.ColIndexToField(cc.ColIndex);
string ColumnName = e.TableControl.TableDescriptor.Columns[index].Name;

if(!summayrecord.Contains( rd.Name) )
{

Hashtable summaycolumns = new Hashtable();
summaycolumns.Add(ColumnName,cc.Renderer.ControlText);
summayrecord.Add(rd.Name ,summaycolumns );
}
else
{
Hashtable summaycolumns = summayrecord[rd.Name] as Hashtable ;
if(!summaycolumns.Contains( ColumnName))
{
summaycolumns.Add(ColumnName,cc.Renderer.ControlText);
}
else
{
summaycolumns[ColumnName] = cc.Renderer.ControlValue;
}
summayrecord[rd.Name] = summaycolumns;

}
}
#endregion
}

}
}


AD Administrator Syncfusion Team January 30, 2007 07:44 PM UTC

Hi,

Thanks....with this code i could able to modify the summary...but one problem i am facing is if summary is changed then all the lower group summary values also get changed to same value...i need to have control on lower group summary value and update lower group summary based on some algorithm..
Please can you explain me how to achieve this??

Thanks
Harshad


AD Administrator Syncfusion Team January 31, 2007 08:16 PM UTC

Hi Harshad,

Please refer the following forum thread and let me know if you are trying something different.
http://www.syncfusion.com/support/forums/message.aspx?&MessageID=49541

Best Regards,
Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon