473,322 Members | 1,540 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,322 software developers and data experts.

Custom Color Themes

I would like to write my Windows Form app so I can set the colors of the
different controls based on a color scheme. The end goal would be to be
able to go into the properties window of a textbox and set the background
color to a "custom" named color. This color would appear in the IDE during
design time.

I could then change the definition of the "custom" named color and the
application would adjust accordingly. The custom name could be
"DansColors.TextBoxColor" which is just some random color I pick. If I
change the definition of DansColors.TextBoxColor then the entire app would
reflect the change as well.

Is this possible or what is the closest mechanism I can use to get to this
result?

Thanks
Dan Tallent
Aug 23 '08 #1
3 6416
"Dan Tallent" <sp**@microsoft.comwrote:
I would like to write my Windows Form app so I can set the colors of the
different controls based on a color scheme.
Why reinvent the wheel? Windows supports this at the OS level, and users
probably aren't going to bother setting up a complete colour scheme just for
*one application*.
Is this possible or what is the closest mechanism I can use to get to this
result?
foreach (Control c in myForm.Controls)
{
if (c is TextBox) /* set textbox colours */
else if (c is CheckBox) /* ... you get the idea */

if (c.HasChildren) // ...run this loop again recursively for that control
}

If you want to specify every colour -- e.g. 3D edge shading as well as the
simple foreground and background -- then you are likely to have to do some
custom painting on your controls.

Eq.
Aug 23 '08 #2
I'm not expecting the end user to set colors. What I am attempting to do is
make it easier to change the colors of the applications without having to
revisit each control.
The current method for changing the background color of a textbox is simply
to change the BackColor property in the IDE during design time. All I
really want to do is create a named color
where I can set the name and the value of the color itself. Then within
the IDE use this newly created named color.

Is this possible ?

"Paul E Collins" <fi******************@CL4.orgwrote in message
news:9e******************************@bt.com...
"Dan Tallent" <sp**@microsoft.comwrote:
>I would like to write my Windows Form app so I can set the colors of the
different controls based on a color scheme.

Why reinvent the wheel? Windows supports this at the OS level, and users
probably aren't going to bother setting up a complete colour scheme just
for *one application*.
>Is this possible or what is the closest mechanism I can use to get to
this result?

foreach (Control c in myForm.Controls)
{
if (c is TextBox) /* set textbox colours */
else if (c is CheckBox) /* ... you get the idea */

if (c.HasChildren) // ...run this loop again recursively for that
control
}

If you want to specify every colour -- e.g. 3D edge shading as well as the
simple foreground and background -- then you are likely to have to do some
custom painting on your controls.

Eq.


Aug 24 '08 #3
"Dan Tallent" <sp**@microsoft.comwrote:
All I really want to do is create a named color where I can set the name
and the value of the color itself. Then within the IDE use this newly
created named color. Is this possible ?
It's not really possible. You can't add new colours to the ForeColor,
BackColor etc. dropdowns in the Designer, because those are class properties
of type Color, and that type is already defined to contain the standard
colours and nothing else.

I suppose you could inherit from each of the standard Windows Forms controls
you want to use, creating e.g. DansTextBox that inherits from TextBox -- and
give them some extended properties to support a new colour type you had
defined -- but I think it would be a pain, and you'd have to write
additional code to get the Designer to display your non-standard colour type
*as* a colour.

Personally, I think I would use the Designer normally -- with system colours
like Control and Info, instead of absolutely fixed colours like Red and
Blue -- and apply the custom set of colours at run-time.

Eq.
Aug 24 '08 #4

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

Similar topics

0
by: Full Decent | last post by:
Hey again! In my quest to make proper use of OO PHP I would like to ask for a critique of the current method of doing themes in the Camera Life (http://fdcl.sf.net) software and see if an OO...
1
by: aspnet20vb_mike | last post by:
I have a Custom Control which inherits from GridView. I call it GridViewSort and it is in a namespace "PDS.WebControls". I add it to the Toolbox, drop it on my WebForm and it shows up and...
4
by: Sean | last post by:
My experience now working with master pages on and off for 6 months is that they can be very dangerous when working with themes. One example in particular is the changes I made to my banner menu...
6
by: Clinton Farleigh | last post by:
Hi, I was going to ask a question, but I think I've answered it so now I am going to rant about how crappy ASP.NET themes are instead. As I've indicated above, my problem today is with themes....
3
by: WT | last post by:
Hello, I need to list all available themes for a .NET app, is there any API in ..NET2 for this or should I explore the folder files using IO methods ? Thanks for indication CS
11
by: New Bee | last post by:
Hi, I have been looking at Themes and Skins today and now resonably understand how they work at a ground level. But I have a couple of questions. 1. ) StyleSheetTheme I dont understand...
1
by: =?Utf-8?B?V29ua28gdGhlIFNhbmU=?= | last post by:
Hello All-- Just a general (or perhaps loaded) question - is it considered good or bad practice to use code-behind with a CustomControl.generic.xaml file? For instance, with a control I'm...
1
by: Cramer | last post by:
Using 3.5: Suppose I have defined 20+ themes (including multiple graphics, ..skin files, and css files per theme), and I want to make those themes *available* to all the Web sites on my Web server....
7
by: Linda Liu[MSFT] | last post by:
Hi George, I have downloaded your sample solution and built it on my machine. I got a compilation error indicating that the type of "CustomResources" doesn't exist in the following xaml code: ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.