The Syncfusion native Blazor components library offers 70+ UI and Data Viz web controls that are responsive and lightweight for building modern web apps.
.NET PDF framework is a high-performance and comprehensive library used to create, read, merge, split, secure, edit, view, and review PDF files in C#/VB.NET.
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;
}
}
}
ADAdministrator Syncfusion Team 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.
VIVirgilSeptember 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.
ADAdministrator Syncfusion Team 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
VIVirgilSeptember 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.