PC Review


Reply
Thread Tools Rating: Thread Rating: 2 votes, 3.00 average.

Change font color for certain rows in DataGridview

 
 
Elmo Watson
Guest
Posts: n/a
 
      3rd Aug 2007
In ASP.Net, using a Gridview, you can conditionally set the forecolor of
each row (or column), based on certain criteria using the RowDataBound event

But I can't find an event that is similar in WinForms

I need to set the forecolor to red, if the the entry type (in column 1) is a
1 - -

How would I do this in a DataGridView?


 
Reply With Quote
 
 
 
 
Elmo Watson
Guest
Posts: n/a
 
      3rd Aug 2007
Also forgot to mention - the column I'm using for the condition is invisible



"Elmo Watson" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> In ASP.Net, using a Gridview, you can conditionally set the forecolor of
> each row (or column), based on certain criteria using the RowDataBound
> event
>
> But I can't find an event that is similar in WinForms
>
> I need to set the forecolor to red, if the the entry type (in column 1) is
> a 1 - -
>
> How would I do this in a DataGridView?
>



 
Reply With Quote
 
 
 
 
ClayB
Guest
Posts: n/a
 
      4th Aug 2007
You can try using th eCellFormatting event.

void dataGridView1_CellFormatting(object sender,
DataGridViewCellFormattingEventArgs e)
{
object val = dataGridView1["Col1", e.RowIndex].Value;
if (e.RowIndex > -1 && e.ColumnIndex >= -1
&& val != null && val.Equals(2))
{
e.CellStyle.BackColor = Color.Red;
}
}

====================
Clay Burch
Syncfusion, Inc.

 
Reply With Quote
 
nikhil soni
Guest
Posts: n/a
 
      25th Nov 2010
Thank you very much.it really help me to solve my Issue

Nikhil Soni

> On Friday, August 03, 2007 4:34 PM Elmo Watson wrote:


> In ASP.Net, using a Gridview, you can conditionally set the forecolor of
> each row (or column), based on certain criteria using the RowDataBound event
>
> But I can't find an event that is similar in WinForms
>
> I need to set the forecolor to red, if the the entry type (in column 1) is a
> 1 - -
>
> How would I do this in a DataGridView?



>> On Friday, August 03, 2007 5:10 PM Elmo Watson wrote:


>> Also forgot to mention - the column I am using for the condition is invisible



>>> On Friday, August 03, 2007 8:46 PM ClayB wrote:


>>> You can try using th eCellFormatting event.
>>>
>>> void dataGridView1_CellFormatting(object sender,
>>> DataGridViewCellFormattingEventArgs e)
>>> {
>>> object val = dataGridView1["Col1", e.RowIndex].Value;
>>> if (e.RowIndex > -1 && e.ColumnIndex >= -1
>>> && val != null && val.Equals(2))
>>> {
>>> e.CellStyle.BackColor = Color.Red;
>>> }
>>> }
>>>
>>> ====================
>>> Clay Burch
>>> Syncfusion, Inc.



>>> Submitted via EggHeadCafe
>>> Custom task processes in SharePoint Designer Workflows
>>> http://www.eggheadcafe.com/tutorials...workflows.aspx

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Automatic font color is white change automatic font color James Niland Microsoft Frontpage 2 26th May 2009 10:53 PM
FONT / ROW ACCESS 2007 Unable to change font size or colour of individual text or heigth of individual rows without all text & rows changing moto Microsoft Access 1 12th Nov 2008 08:23 PM
dataGridView.Rows.Count and datagridview.RowCount SePp Microsoft C# .NET 1 15th Jan 2008 11:27 AM
DataGridView: Change the color of edited rows RSH Microsoft C# .NET 0 29th Dec 2005 08:14 PM
Re: Hard drive <font color="blue"><B>data</B></font&g t; <font color="blue"><B>recovery</B></fo nt> services? halleyscomet@gmail.com Storage Devices 0 7th Dec 2004 04:11 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:46 AM.