Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do you change the DataGrid Control Color?

Status
Not open for further replies.

Bojangles

Programmer
May 27, 2000
32
I have checked all the threads and saw where some have asked this same question, but found no response that answered it. I AM NOT CONCERNED WITH THE COLOR OF THE ROW IN THE DATAGRID! I simply want to change the color of the Datagrid CONTROL itself! It is GREY! I want to change the GREY to another color. Not the row! The Datagrid control itself!

Again....How do you change the color of the datagrid control from gray to another color?

Thank you so much for your help?

Bojangles
 


Sorry, but there is no direct way.

What is it that you want to change? The headers and row selectors, or the empty space when there are fewer columns/rows than what will fit onto the grid?


[/b][/i][/u][sub]*******************************************************
General remarks:
If this post contains any suggestions for the use or distribution of code, components or files of any sort, it is still your responsibility to assure that you have the proper license and distribution rights to do so!
 
Thanks for the reply CC. I want to make ALL of the gray area another color. That is the headers, row selectors, and the empty space when there are fewer columns/rows than will fit the grid. I simply want the background of the control to be blue, or red, or whatever instead of gray. Do you know of any way to do that?
Thanks,
Bojangles
 
To be sure there must be a way to change the color of the datagrid from that dull gray to some other color.

Any help would be greatly appreciated.

Thanks,
Bojangles
 
Ok, here is a partial answer.

The default background for the datagrid control (and unfortunately, many other controls) comes from the windows setting for "3D objects, color 1". You can set it (one way) by right-clicking on the desktop, properties, appearance, (then advanced in xp), then selecting 3d objects, and changing color 1 to another color.

I haven't looked into it, but I'm sure you could probably do that programatically by using one of the windows api calls. Additionally, I believe there is a registry entry that holds all these settings.

Of course the bad side to all this is that you will change the color of not just the grid, but all 3d controls (which affects alot of things...just change it to some ugly color and try it for awhile. B-)

If you app has the focus and is full screen (or a large portion of it), you could change the color this way and then change it back to the default color before exiting your app. Just some semi-random thoughts. %-)
Mark
 
>you could change the color this way and then change it back to the default color before exiting your app

mspears3: Thanks for your response.

I was aware of this, and believe I mentioned it sometime ago in another thread as a possibility, but, as I mentioned then, it is not a good solution from the programer's side.

Changing the Windows settings with resepct to the colors of 3D controls, is something to be left totally up to the user, and not the programmer, and so it cannot be really even considered as a partial solution in this manner.

An application may not be considered a professional application if it was ignorant of every other program which the user starts, and ignorant of certain Windows standards.
In this case, with the proposed solution, when the user switches between programs, while the one which changed system colors is still running, all other apps will have color changes and this would probably be unacceptable.

Therefore, if it is desired for the color to be changed, then it should be left up to the user to do so, and not the programmer.

The only possible exception to this would be to change the system colors when the application looses focus and gains focus. But, as you say, many other controls in the application may suffer from this.
You would need to create a hook in order to capture the apps lost/got focus though.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top