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.
Unfortunately, activation email could not send to your email. Please try again.

Is this the right way to set the styles in a GDBG?

Thread ID:





33826 Aug 26,2005 10:19 AM Sep 13,2005 02:14 PM Windows Forms 4
Tags: GridControl
Atith Pagdi
Asked On August 26, 2005 10:19 AM

The colour of the cell text and "bold" doesn''t change with this code, but the text appears as set by the style. This is my own method, and not an event handler. Thanks. private void FormatGrid(string source) { if (source == "Main") { int numOfRows = GetNumOfRowsInMain(); int rowIndex = 0; for (rowIndex = 6; rowIndex <= numOfRows; rowIndex += 6) { if (this.dgTest[rowIndex, 2].Text == "N") { GridStyleInfo style = new GridStyleInfo(); // Set some properties style.BackColor = SystemColors.Menu; style.TextColor = SystemColors.HotTrack; //DataRow dr = GetDataRowAtCoOrdinates(rowIndex); style.Text = this.dgTest[rowIndex, 1].Text; style.Font.Bold = true; GridRangeInfo range = GridRangeInfo.Cells(rowIndex, 1, rowIndex + 2, 1); this.dgTest.Model.ChangeCells(range, style, Syncfusion.Styles.StyleModifyType.Override); // Create a GridRangeInfo object // GridRangeInfo range = GridRangeInfo.Cells(1,1,5,5); // this.dgTest.Model[rowIndex, 1].TextColor = Color.Red; // this.dgTest.Model[rowIndex + 1, 1].TextColor = Color.Red; // this.dgTest.Model[rowIndex + 2, 1].TextColor = Color.Red; } } }

Administrator [Syncfusion]
Replied On August 26, 2005 02:21 PM

You cannot set anything other than style.Text or style.CellValue on individual cells or cellranges in a GridDataBoundGrid. So, you cannot set style.Font.Bold the way you are trying to do it. Instead you have to use an event, and provide the style dynamically. See http://www.syncfusion.com/support/kb/grid/Default.aspx?ToDo=view&questId=83 and http://www.syncfusion.com/support/kb/grid/Default.aspx.

Replied On September 13, 2005 07:45 AM

The example given covers only the background color, which is found in the Style property available through the GridPrepareViewStyleInfoEventArgs variable passed in as an event arg to the PrepareViewStyle. I am interested in how to set the foreground color of the text in a GDBG. I found the TextColor property, but this appears to not be usable within this event.

Administrator [Syncfusion]
Replied On September 13, 2005 11:51 AM

Hi Virgil, Here is a small sample that work fine for Style.TextColor. Do you see the issue in this sample too? Condition Coloring_CS.zip Best regards, Jay N

Replied On September 13, 2005 02:14 PM

I swear I looked all over the GridStyleInfo and did not see the TextColor. Your example works great and now so does my program. Thanks.


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.

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.