473,407 Members | 2,306 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Setting Colors in Base Form to be used by Child Forms

I want to be able to define standard colors in a base form, then have
child forms use those values instead of standard colors.

Ex in my base form I want to do this:

Color myColor = System.Drawing.SystemColors.Control;
Then in my child form in the designer, I want to be able to enter
"myColor" in the BackColor property.

This doesn't work since it's expecting an Int32. Is there a standard
way to externalize my color settings? This seems like it would be a
good technique to standardize color usage across many applications.

Jun 27 '06 #1
1 1857
Hi Demi,

The BackColor property of a System.Windows.Forms.Control expects a
System.Drawing.Color structure not an Int32.

The BackColor property of a Control, in the PropertyGrid of the VS.NET Forms
designer, uses a custom Editor to allow the user to select a color. The
same display allows you to add your own colors by clicking the "Custom" tab
and right-mouse clicking in one of the blank white spaces at the bottom.

The colors you create using this dialog, however, are not 'named' and cannot
be accessed in code from any variable just by adding them to the dialog.
The colors cannot be set by referencing a variable in code. This method of
defining custom colors is only available to the user at design time, per
instance of VS.NET and custom colors aren't persisted between instances of
VS.NET.

Maybe you could write a VS.NET addin that would persist custom colors with
your project or solution.

If you want a more robust solution you should write a class to encaspulate
application-wide colors and styles to controls. You'll have to apply the
styles to controls at runtime like a stylesheet is applied to a webpage at
runtime.

HTH

"Demi" <d3*****@yahoo.com> wrote in message
news:11**********************@p79g2000cwp.googlegr oups.com...
I want to be able to define standard colors in a base form, then have
child forms use those values instead of standard colors.

Ex in my base form I want to do this:

Color myColor = System.Drawing.SystemColors.Control;
Then in my child form in the designer, I want to be able to enter
"myColor" in the BackColor property.

This doesn't work since it's expecting an Int32. Is there a standard
way to externalize my color settings? This seems like it would be a
good technique to standardize color usage across many applications.

Jun 27 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: Michael Bierman | last post by:
Please forgive the simplicy of this question. I have the following code which attempts to determine the color of some text and set other text to match that color. It works fine in Firefox, but does...
9
by: TD | last post by:
I am trying to add transactions to my code. The original code worked fine until I followed an example to setup transactions, now the code does strange things, but no error messages. Could...
2
by: Mystery Man | last post by:
We have an MDI application that is not setting always setting focus to the newly corrected MDI. It is creating the form and it is the topmost but it does not have focus. The code we are using to...
4
by: Gecko | last post by:
I noticed that every time I override a class member, the intellisense behavior is to automatically add a call to the base class of the overridden member such as: public override void...
11
by: Paul Smith | last post by:
I have a button on my web page the backcolor of which I want to change: btnSample.backcolor = ???????? I want the color to be Gainsboro However I enter Gainsboro or color.Gainsboro I have...
3
by: feng | last post by:
We have a windows form project that has multiple child forms inherit from one base form. In our base form's form load event handler, we have some common logic in there. These common logic is...
1
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting"...
5
by: Michael R | last post by:
Searching the net I've found a simple technique to add row numbers and alternate colors (for the even and the uneven row) to a continuous form. 1st step: Create a textbox, send it to background...
1
by: Jeff | last post by:
I tend to be a bit behind the times, sometimes a generation further that I want. So, I've been thing about the "*" selector. I've noticed that unlike body, it styles form fields and form...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.