Solved

Data Grid View Coding question

Posted on 2011-09-07
2
252 Views
Last Modified: 2012-05-12
Hello Experts

I can do the following:

foreach (TabPage tp in tabc__all.TabPages
   foreach (Control lbl in tp.Controls) lbl.BackColor = Color.Blue;

My question is how do I do the same with datagridviews, so something like the following:


foreach (TabPage tp in tabc__all.TabPages
   foreach (Datagridview dgv in tp.Controls) dgv.BackColor = Color.Blue;

I get an error with this code,  Just a beginning programmer so Detail code please,  Thanks

0
Comment
Question by:crp81
2 Comments
 
LVL 28

Accepted Solution

by:
strickdd earned 500 total points
ID: 36497211
Datagridview foundGrid;

foreach (TabPage tp in tabc__all.TabPages
{
   foreach (Control dgv in tp.Controls) dgv.BackColor = Color.Blue;
   {
          if(dgv is Datagridview)
          {
                 foundGrid = (Datagridview)dgv;
                 foundGrid.BackColor = Color.Blue;
          }
    }
}
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question