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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Row / Column Totals

Thread ID:

Created:

Updated:

Platform:

Replies:

37752 Nov 29,2005 09:23 PM UTC Nov 30,2005 12:52 AM UTC WinForms 4
loading
Tags: GridControl
Michael Scott
Asked On November 29, 2005 09:23 PM UTC

I am adding row/column totals to a regular grid using the below text. Is there a better way to *shade* them? The reason why I ask is I will later need to wipe out the entire grid, and recreate row/column totals - which could very well be a completely different row/column. I need a way to remove the shading (currently using a style) on the current *last* row/column, redraw the entire grid, then re-apply the shading to the *new* last row/column. Suggestions? Here''s the current code for shading - though I haven''t begun the code to unshade the current row/column, only to apply that shading to the new last row/column: // 5. Add Column Totals if (HAS_COL_TOTAL) { gridControlConfMatrix[0,cols].Text = "Totals"; // gridControlConfMatrix.ColStyles[cols].CellType = "Header"; // gridControlConfMatrix.ColStyles[cols].BaseStyle = "Heading"; // gridControlConfMatrix.ColStyles[cols].Font.Bold = true; gridControlConfMatrix.ColStyles[cols].BaseStyle = "Row Header"; for (int i = 0; i < this.numRows; i++) { int nColTotal = 0; for (int j = 0; j < this.numCols; j++) nColTotal += this.intArray[i+1,j+1]; gridControlConfMatrix[i+1,cols].CellValue = nColTotal; // gridControlConfMatrix[i+1,cols].BackColor = Color.FromArgb(208,208,208); } } // 6. Add Row Totals if (HAS_ROW_TOTAL) { gridControlConfMatrix[rows,0].Text = "Totals"; // gridControlConfMatrix.RowStyles[rows].CellType = "Header"; // gridControlConfMatrix.RowStyles[rows].BaseStyle = "Heading"; // gridControlConfMatrix.RowStyles[rows].Font.Bold = true; gridControlConfMatrix.RowStyles[rows].BaseStyle = "Column Header"; for (int i = 0; i < this.numCols; i++) { int nRowTotal = 0; for (int j = 0; j < this.numRows; j++) nRowTotal += this.intArray[j+1,i+1]; gridControlConfMatrix[rows,i+1].CellValue = nRowTotal; // gridControlConfMatrix[rows,i+1].BackColor = Color.FromArgb(208,208,208); } }

Michael Scott
Replied On November 29, 2005 09:24 PM UTC

BTW, I''m still trying to find the best way to force the row/column total NOT have a gradient shading pattern, as the row/column borders do (at least on my machine).

Administrator [Syncfusion]
Replied On November 30, 2005 12:36 AM UTC

To set the last row/column to be a special color (no matter where the last row/column is), you can use the PrepareViewStyleInfo event.
private void gridControl1_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e)
{
	if(e.RowIndex == this.gridControl1.RowCount && e.ColIndex > 0)
	{
		e.Style.BackColor = Color.Red;
                e.Style.CellType = "Static";
	}
	else if(e.ColIndex == this.gridControl1.ColCount && e.RowIndex > 0)
	{
		e.Style.BackColor = Color.Red;
                e.Style.CellType = "Static";
	}
}
The reason you are getting the gradient colors is because you are setting the CellType to "Header". The above code uses a Static celltype instead.

Michael Scott
Replied On November 30, 2005 12:41 AM UTC

I''ll give that a shot, but what I''m looking for is to have this last row/column *look* similar to a row/col border. I also need to have the entire row / col selected by clicking the last cell in that row/column - and act as if I''d clicked on the border instead. Possible?

Administrator [Syncfusion]
Replied On November 30, 2005 12:52 AM UTC

You want the last row and column to look like a header but not have the header shading used by the grid''s default header. If so, try using the static celltype but also try setting e.Style.CellAppearance = GridCellAppearance.Raised; To handle selecting cells when you click a particular cell, try handling the CellClick event. In the handler, call grid.Selections.SelectRange to select th erange you want to select.

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;