I was wondering if someone could help me adjust my GridSummaryRows.cs to display a total from my data table. Below is my form load:
private void Proposal_Load(object sender, System.EventArgs e)
{
this.Proposaltab.Height=SystemInformation.PrimaryMonitorSize.Height-(115); //Rqmt# 31. 07/11/06
this.Proposaltab.Width = SystemInformation.PrimaryMonitorSize.Width-20;
this.lblMessageBox.Location = new System.Drawing.Point(2, 2); //Rqmt# 31. 07/11/06
this.Proposaltab.Location = new System.Drawing.Point(0,50);
Proposaltab.TabPages[0].AutoScroll=true;
Proposaltab.TabPages[1].AutoScroll=true;
Proposaltab.TabPages[2].AutoScroll=true;
Proposaltab.TabPages[3].AutoScroll=true;
Proposaltab.TabPages[4].AutoScroll=true;
Proposaltab.TabPages[5].AutoScroll=true;
Proposaltab.TabPages[6].AutoScroll=true;
Proposaltab.TabPages[7].AutoScroll=true;
Proposaltab.TabPages[8].AutoScroll=true;
Proposaltab.TabPages[9].AutoScroll=true;
access.BLL.ProfileBLL pr=new access.BLL.ProfileBLL();
OleDbDataReader rd =pr.ProfileFillBL(lbRepp.Text);
while(rd.Read())
{
tbPathADA.Text=rd[13].ToString();
}
try
{
dataGridA.Visible=true;
string p = label1.Text;
string [] q=p.Split('' '');
access.BLL.PagesBLL prop = new access.BLL.PagesBLL();
string [] pi=prop.savekeydata(q[0].ToString());
lblSDataA.Text=pi[0] + "\n" + "Customer No:" + pi[1] + "\n"+ "Customer Name:" + pi[2]+ "\n"+ "Rep No:" + pi[3] +"\n" + "Rep Name:"+ pi[4] +"\n";
DataTable dt =prop.proposalload(q[0].ToString(), "A");
double pia=0;
double nia=0;
double nigrowthda=0;
double nigrowthpa=0;
for(int i =0; i
{
pia += Convert.ToDouble(dt.Rows[i]["PI Revenue"].ToString().TrimStart(''$''));
if(dt.Rows[i]["NI Revenue"].ToString()=="RATE NOT AVAILABLE")
{
nia += 0;
}
else
{
nia += Convert.ToDouble(dt.Rows[i]["NI Revenue"].ToString().TrimStart(''$''));
}
}
nigrowthda= nia-pia;
nigrowthpa=(nigrowthda/pia)*100;
DataRow dr;
dr =dt.NewRow();
dr["Cluster Name"]=" ";
dr["DirNum"]="TOTAL";
dr["DirNumber"]=0;
dr["Dirname"]="";
dr["Selling Pub Year"]="";
dr["# Of Items"]="";
dr["PI Item"]="";
dr["PI Incentive Program No"]="";
dr["NI Item"]="";
dr["NI Discount"]="";
dr["Listingname"]="";
dr["Listingtele"]="";
dr["HeadingCode"]="";
dr["HeadingName"]="";
dr["Discountable"]="";
dr["PI Revenue"]="$" + String.Format("{0:N}", Convert.ToDouble(pia.ToString()));
dr["NI Revenue"]= "$"+String.Format("{0:N}", Convert.ToDouble(nia.ToString()));
dr["NI Growth $"]="$"+String.Format("{0:N}", Convert.ToDouble(nigrowthda.ToString()));
dr["NI Growth %"]=String.Format("{0:N}", Convert.ToDouble(Math.Round(nigrowthpa)))+"%";
dt.Rows.Add(dr);
for(int i =0;i {
if(dt.Rows[i][13].ToString().Equals("RATE NOT AVAILABLE"))
{
dt.Rows[i][13]="RATE N/A";
}
if(dt.Rows[i][14].ToString().Equals("RATE NOT AVAILABLE"))
{
dt.Rows[i][14]="RATE N/A";
}
if(dt.Rows[i][15].ToString().Equals("RATE NOT AVAILABLE"))
{
dt.Rows[i][15]="RATE N/A";
}
}
int kl= dt.Rows.Count;
#region datagridA styles
dataGridA.GridBoundColumns.Clear();
Syncfusion.Windows.Forms.Grid.GridBoundColumn dgcsa0 = new Syncfusion.Windows.Forms.Grid.GridBoundColumn();
dgcsa0.HeaderText = "Dir Num"; //Rqmt# 2. 07/07/06
dgcsa0.MappingName = "DirNum";
dgcsa0.StyleInfo.HorizontalAlignment = GridHorizontalAlignment.Left;
Syncfusion.Windows.Forms.Grid.GridBoundColumn dgcsa01 = new Syncfusion.Windows.Forms.Grid.GridBoundColumn();
dgcsa01.HeaderText = "Cluster Name"; //Rqmt# 2. 07/07/06
dgcsa01.MappingName = "Cluster Name";
dgcsa01.StyleInfo.HorizontalAlignment = GridHorizontalAlignment.Left;
//Rqmt# 2. 07/10/06
Syncfusion.Windows.Forms.Grid.GridBoundColumn dgcsa = new Syncfusion.Windows.Forms.Grid.GridBoundColumn();
dgcsa.HeaderText = "Directory Name"; //Rqmt# 3. 07/12/06
dgcsa.MappingName = "Dirname";
dgcsa.StyleInfo.HorizontalAlignment = GridHorizontalAlignment.Left;
Syncfusion.Windows.Forms.Grid.GridBoundColumn dgcsb = new Syncfusion.Windows.Forms.Grid.GridBoundColumn();
dgcsb.HeaderText = "Selling Pub Yr"; //Rqmt# 3. 07/12/06
dgcsb.MappingName = "Selling Pub Year";
dgcsb.StyleInfo.HorizontalAlignment = GridHorizontalAlignment.Right;
Syncfusion.Windows.Forms.Grid.GridBoundColumn dgcsa02 = new Syncfusion.Windows.Forms.Grid.GridBoundColumn();
dgcsa02.HeaderText = "Number of Items"; //Rqmt# 2. 07/07/06
dgcsa02.MappingName = "# Of Items";
dgcsa02.StyleInfo.HorizontalAlignment = GridHorizontalAlignment.Left;
Syncfusion.Windows.Forms.Grid.GridBoundColumn dgcsc = new Syncfusion.Windows.Forms.Grid.GridBoundColumn();
dgcsc.HeaderText = "PI Item"; //Rqmt# 3. 07/12/06
dgcsc.MappingName = "PI Item";
dgcsc.StyleInfo.HorizontalAlignment = GridHorizontalAlignment.Left;
Syncfusion.Windows.Forms.Grid.GridBoundColumn dgcsd = new Syncfusion.Windows.Forms.Grid.GridBoundColumn();
dgcsd.HeaderText = "PI Disc Program No"; // Rqmt# 5. 06/28/06 //Rqmt# 3. 07/12/06
dgcsd.MappingName = "PI Incentive Program No";
dgcsd.StyleInfo.HorizontalAlignment = GridHorizontalAlignment.Right;
Syncfusion.Windows.Forms.Grid.GridBoundColumn dgcsf = new Syncfusion.Windows.Forms.Grid.GridBoundColumn();
dgcsf.HeaderText = "NI Item"; //Rqmt# 3. 07/12/06
dgcsf.MappingName = "NI Item";
dgcsf.StyleInfo.HorizontalAlignment = GridHorizontalAlignment.Left;
Syncfusion.Windows.Forms.Grid.GridBoundColumn dgcsg = new Syncfusion.Windows.Forms.Grid.GridBoundColumn();
dgcsg.HeaderText = "NI Disc Program No"; // Rqmt# 5. 06/28/06 & Rqmt# 3. 07/12/06(And Related to all datagrid HeaderText)
dgcsg.MappingName = "NI Incentive Program No";
dgcsg.StyleInfo.HorizontalAlignment = GridHorizontalAlignment.Right;
Syncfusion.Windows.Forms.Grid.GridBoundColumn dgcsi1 = new Syncfusion.Windows.Forms.Grid.GridBoundColumn();
dgcsi1.HeaderText = "Listing Name"; //Rqmt# 3. 07/12/06(And Related to all datagrid HeaderText)
dgcsi1.MappingName = "listingname";
dgcsi1.StyleInfo.HorizontalAlignment = GridHorizontalAlignment.Left;
Syncfusion.Windows.Forms.Grid.GridBoundColumn dgcsi2 = new Syncfusion.Windows.Forms.Grid.GridBoundColumn();
dgcsi2.HeaderText = "Listing Phone No"; //Rqmt# 3. 07/12/06(And Related to all datagrid HeaderText)
dgcsi2.MappingName = "listingtele";
dgcsi2.StyleInfo.HorizontalAlignment = GridHorizontalAlignment.Left;
Syncfusion.Windows.Forms.Grid.GridBoundColumn dgcsi = new Syncfusion.Windows.Forms.Grid.GridBoundColumn();
dgcsi.HeaderText = "Heading Code"; //Rqmt# 3. 07/12/06(And Related to all datagrid HeaderText)
dgcsi.MappingName = "HeadingCode";
dgcsi.StyleInfo.HorizontalAlignment = GridHorizontalAlignment.Left;
Syncfusion.Windows.Forms.Grid.GridBoundColumn dgcsj = new Syncfusion.Windows.Forms.Grid.GridBoundColumn();
dgcsj.HeaderText = "Heading Name"; //Rqmt# 3. 07/12/06
dgcsj.MappingName = "HeadingName";
dgcsj.StyleInfo.HorizontalAlignment = GridHorizontalAlignment.Left;
Syncfusion.Windows.Forms.Grid.GridBoundColumn dgcsk = new Syncfusion.Windows.Forms.Grid.GridBoundColumn();
dgcsk.HeaderText = "Discountable";
dgcsk.MappingName = "Discountable";
dgcsk.StyleInfo.HorizontalAlignment = GridHorizontalAlignment.Center;
Syncfusion.Windows.Forms.Grid.GridBoundColumn dgcsl = new Syncfusion.Windows.Forms.Grid.GridBoundColumn();
dgcsl.HeaderText = "PI Revenue $"; //Rqmt# 3. 07/12/06(And Related to all datagrid HeaderText)
dgcsl.MappingName = "PI Revenue";
dgcsl.StyleInfo.HorizontalAlignment = GridHorizontalAlignment.Right; //Rqmt# 3. 07/12/06(And Related to all datagrid HeaderText and Width)
Syncfusion.Windows.Forms.Grid.GridBoundColumn dgcsm = new Syncfusion.Windows.Forms.Grid.GridBoundColumn();
dgcsm.HeaderText = "NI Revenue $"; //Rqmt# 3. 07/12/06
dgcsm.MappingName = "NI Revenue";
dgcsm.StyleInfo.HorizontalAlignment = GridHorizontalAlignment.Right;
Syncfusion.Windows.Forms.Grid.GridBoundColumn dgcsn = new Syncfusion.Windows.Forms.Grid.GridBoundColumn();
dgcsn.HeaderText = "NI Growth $"; //Rqmt# 3. 07/12/06
dgcsn.MappingName = "NI Growth $";
dgcsn.StyleInfo.HorizontalAlignment = GridHorizontalAlignment.Right;
Syncfusion.Windows.Forms.Grid.GridBoundColumn dgcso = new Syncfusion.Windows.Forms.Grid.GridBoundColumn();
dgcso.HeaderText = "NI Growth %"; //Rqmt# 3. 07/12/06
dgcso.MappingName = "NI Growth %";
dgcso.StyleInfo.HorizontalAlignment = GridHorizontalAlignment.Right;
Syncfusion.Windows.Forms.Grid.GridBoundColumn dgcsp = new Syncfusion.Windows.Forms.Grid.GridBoundColumn();
dgcsp.HeaderText = "Delete Item";
dgcsp.MappingName = "DELETE_ITEM";
dataGridA.GridBoundColumns.Add(dgcsa0);
dataGridA.GridBoundColumns.Add(dgcsa01);
dataGridA.GridBoundColumns.Add(dgcsa02);
dataGridA.GridBoundColumns.Add(dgcsa);
dataGridA.GridBoundColumns.Add(dgcsb);
dataGridA.GridBoundColumns.Add(dgcsc);
dataGridA.GridBoundColumns.Add(dgcsd);
dataGridA.GridBoundColumns.Add(dgcsf);
dataGridA.GridBoundColumns.Add(dgcsg);
dataGridA.GridBoundColumns.Add(dgcsi1);
dataGridA.GridBoundColumns.Add(dgcsi2);
dataGridA.GridBoundColumns.Add(dgcsi);
dataGridA.GridBoundColumns.Add(dgcsj);
dataGridA.GridBoundColumns.Add(dgcsk);
dataGridA.GridBoundColumns.Add(dgcsl);
dataGridA.GridBoundColumns.Add(dgcsm);
dataGridA.GridBoundColumns.Add(dgcsn);
dataGridA.GridBoundColumns.Add(dgcso);
dataGridA.GridBoundColumns.Add(dgcsp);
this.dataGridA.BaseStylesMap["Header"].StyleInfo.BackColor=Color.AliceBlue;
this.dataGridA.BaseStylesMap["Header"].StyleInfo.WrapText = true;
this.dataGridA.BaseStylesMap["Header"].StyleInfo.AutoSize = true;
//this.dataGridA.Model.RowHeights.ResizeToFit(GridRangeInfo.Row(1));// here 2 is the header row index.
#endregion
this.dataGridA.Model.RowHeights[0] = 30;
//this.dataGridA.ListBoxSelectionMode = SelectionMode.MultiExtended;
dataGridA.Location=new System.Drawing.Point(25, 200);
dataGridA.Size=new System.Drawing.Size(3000, 25*(kl));
dataGridA.DataSource= dt;
//***************************************************************************
//create a summary row...
sumRow = new GridSummaryRow();
//define the summary type for each column
object[] summaryTypes = new object[this.dataGridA.Model.ColCount];
for(int i = 0; i < this.dataGridA.Model.ColCount; ++i)
{
if( i == 2 || i == 14 || i == 15 || i == 16 || i == 17 ) //sum these
{
summaryTypes[i] = GridSummaryRow.SummaryType.Sum;
}
else //no summary
summaryTypes[i] = GridSummaryRow.SummaryType.None;
}
//two ways to wire the summary row
//1) use default table style
//sumRow.WireSummaryRow(this.dataGridA, summaryTypes);
//2) or set each column style somehow....
GridStyleInfo[] styles = new GridStyleInfo[this.dataGridA.Model.ColCount];
for(int i = 0; i < this.dataGridA.Model.ColCount; ++i)
{
styles[i] = new GridStyleInfo((GridStyleInfoStore)this.dataGridA.Binder.InternalColumns[i].StyleInfo.Store.Clone());
styles[i].Font.Bold = true;
}
sumRow.WireSummaryRow(this.dataGridA, summaryTypes, styles);
//this.dataGridA.EnableAddNew = false;
//padd the grid''s client area with empty rows
this.dataGridA.Model.Options.DisplayEmptyRows = true;
//***************************************************************************
Cursor=Cursors.Default;
}
catch(Exception ex)
{
lblMessageBox.Visible=false;
lblMessageBox.Text = null;
lblMessageBox.Visible=true;
lblMessageBox.Text = "Unable to Load Proposal." + "\n" + "(Error Desc: " + ex.Message + ")";
}
}
Problem I am having is that the current GridSummaryRows.cs only adds integers. But I need to display a string. Please refer to the atached picture to clearly understand what I need.Thanks
Charlie
add_summary.zip