PC Review


Reply
Thread Tools Rate Thread

DataGridView -- What row am I on?

 
 
Dom
Guest
Posts: n/a
 
      30th Nov 2007
I like to use the AlternateRow option for DataGridViews, so that the
odd rows have a defaut style, and the even rows have an alternate
style, usually just a light blue backcolor.

Sometimes I need to change the style of cell to give a visual clue
about the data, for example, italicise it. But (as far as I know), I
need to know which row I am on, so I can maintain the backcolor. Is
there something like a DataGridView1.Rows[0].IsAlternate property?

Dom
 
Reply With Quote
 
 
 
 
Peter Duniho
Guest
Posts: n/a
 
      30th Nov 2007
On 2007-11-29 18:50:47 -0800, Dom <(E-Mail Removed)> said:

> I like to use the AlternateRow option for DataGridViews, so that the
> odd rows have a defaut style, and the even rows have an alternate
> style, usually just a light blue backcolor.
>
> Sometimes I need to change the style of cell to give a visual clue
> about the data, for example, italicise it. But (as far as I know), I
> need to know which row I am on, so I can maintain the backcolor. Is
> there something like a DataGridView1.Rows[0].IsAlternate property?


It seems to me that if you wanted to know the row # of a given
DataGridViewCell, you could just look at the RowIndex property of the
cell. If you have the row itself then presumably you got it from
somewhere and could know the row # from that, but even if not you could
look at a cell in the rows cell collection and get a RowIndex from that.

But I'm not sure you need to do all of that. If you want to format a
DataGridViewCell as the same as its current format but changing just
one thing, why not get the current DataGridViewCellStyle of the cell
(InheritedStyle or Style, as appropriate), create a new one using that,
and change whatever part of the style you want, leaving the other style
components the same?

Pete

 
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
Refreshing Linq query to update second DataGridView when position in first DataGridView changes Arved Sandstrom Microsoft C# .NET 1 25th May 2008 04:06 AM
dataGridView.Rows.Count and datagridview.RowCount SePp Microsoft C# .NET 1 15th Jan 2008 10:27 AM
DataGridView (.NET 2.0 Windows Forms) Text wrapping in DataGridView Items Chris Hayes Microsoft Dot NET Framework 1 27th Aug 2006 06:07 PM
Clearing selection in DataGridView when user clicks outside the DataGridView control djyakov@gmail.com Microsoft Dot NET Framework Forms 0 16th Feb 2006 06:38 PM
Refreshing datagridview contents after a failed delete in bound datagridview Bob Microsoft VB .NET 0 5th Jan 2006 06:34 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:48 AM.