Solved

Data Grid View Coding question

Posted on 2011-09-07
2
249 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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

746 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now