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

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

Thread ID:





33826 Aug 26,2005 02:19 PM UTC Sep 13,2005 06:14 PM UTC WinForms 4
Tags: GridControl
Atith Pagdi
Asked On August 26, 2005 02:19 PM UTC

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 06:21 PM UTC

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 11:45 AM UTC

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 03:51 PM UTC

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 06:14 PM UTC

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.

Please sign in to access our forum

This page will automatically be redirected to the 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