Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / November 2007

Tip: Looking for answers? Try searching our database.

DataGridView -- What row am I on?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dom - 30 Nov 2007 02:50 GMT
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
Peter Duniho - 30 Nov 2007 04:14 GMT
> 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
[quoted text clipped - 4 lines]
> 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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.