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

Customize Style.Borders.Bottom

Thread ID:





30616 Jun 21,2005 10:22 AM UTC Jun 22,2005 02:41 PM UTC WinForms 4
Tags: GridControl
Mikaël Morvan
Asked On June 21, 2005 10:22 AM UTC

Hi, I used GridGroupingControl I want to customize the bottom border of cells depends on some columns value of the previous rows. Sample : 3 columns : - Col1 string - Col2 double - Col3 double Col1 Col2 Col3 Row 1 10 0 Row 2 0 10 --------------------- Row 3 10 0 Row 4 10 0 Row 5 0 20 --------------------- When (Total(Col2) - Total(Col3) == 0), i want to have a bottom border line on the cells ( Style.Borders.Bottom = new GridBorder(GridBorderStyle.Solid, Color.Red)) How can i do this ? Regards, Mikaël

Administrator [Syncfusion]
Replied On June 21, 2005 11:02 AM UTC

In general, to set conditional cell specific properties, you use the grid.QueryCellStyleInfo event. In your event code, if e.TableCellIdentity points to a cell where you may want to change the e.Style settings, then you would test whatever condition you are using for that particular cell, and if it is true, then change e.Style accordingly. Exactly how you go about testing things things depends upon exactly what you want to test. In your case you are using the difference to two totals, how/what are you totalings? Is it the whole column, or just a few rows in the columns or a grouped set of rows or ??. Are you trying to use a SummaryRow to do these totals, or something else? If you can upload a little sample project showing what you are doing, and explain exactly when you want a red border, maybe we can modify your sample to do this.

Mikaël Morvan
Replied On June 22, 2005 09:06 AM UTC

This sample (WindowsApplication8_4509.zip) show what i want doing. The 2nd gridGroupingControl show the result i want to obtain by the 1st gridGroupingControl, which used event or another method to set conditionaly the red border of rows.

Administrator [Syncfusion]
Replied On June 22, 2005 11:29 AM UTC

Try this code.
private void gridGroupingControl1_TableControlPrepareViewStyleInfo(object sender, GridTableControlPrepareViewStyleInfoEventArgs e)
	if ((e.Inner.ColIndex == 2) || (e.Inner.ColIndex == 3))
		if (e.Inner.Style.Text == "0")
			e.Inner.Style.Text = "";
	GridTableCellStyleInfo style = e.TableControl.Model[e.Inner.RowIndex, e.Inner.ColIndex];
		e.Inner.Style.Borders.Bottom = new GridBorder(GridBorderStyle.Solid, Color.Red);
private bool SumMatches(GridTableCellStyleInfo style)
	if(style.TableCellIdentity.TableCellType != GridTableCellType.RecordFieldCell
		&& style.TableCellIdentity.TableCellType != GridTableCellType.AlternateRecordFieldCell
		|| (style.TableCellIdentity.DisplayElement.ParentRecord == null))
		return false;
	GridRecord rec = style.TableCellIdentity.DisplayElement.ParentRecord as GridRecord;
	int index = this.gridGroupingControl1.Table.FilteredRecords.IndexOf(rec);
	double sum1 = 0;
	double sum2 = 0;
	for(int i = 0; i <= index; ++i)
		Record r = this.gridGroupingControl1.Table.FilteredRecords[i];
		sum1 += (double) r.GetValue("Value1");
		sum2 += (double) r.GetValue("Value2");
	return (Math.Abs(sum1 - sum2) < 1e-7);

Mikaël Morvan
Replied On June 22, 2005 02:41 PM UTC

Thanks, it was exactly what i want.


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