views:

87

answers:

3

How do i change the ForColor of the form, have set the ForeColor to RED but the form still displays in Whte Text. How do i change this.
Am refering to Title Bar Text Color

+1  A: 

Hi Girish, I'm not sure what you are trying to do. ForeColor changes the color for Child Controls on the Form. Here is a sample of use for ForeColor and for writing on a windows Form. Note that the Form ForeColor property is not used when writing directly on the Form through a Graphics object... Put a button on your form and put the code in its event handler ...

private void button1_Click(object sender, EventArgs e)
    {
        this.ForeColor = System.Drawing.Color.Red;
        using (Graphics g = this.CreateGraphics())
        {
            Brush b = new SolidBrush(System.Drawing.Color.Blue);
            g.DrawString("SAMPLE TEXT", SystemFonts.CaptionFont, b, new PointF(50, 50));
            b.Dispose();
        }
    }
oldbrazil
Thanks for the reply Oldbrazil.What you said is right but then how do i change the Form's Title Text ie; "Form1" at the top of the form.I need to change this color.How do i do this ?
GIRISH GMAIL
well, it seems not that simple to change the appearence of the title zone, it is normally handled by the system (think that users may define a theme for their windows ...) Have a look here, I think this is what you are looking for:http://www.codeproject.com/KB/dialog/CustomizeTitleBar.aspx
oldbrazil
+1  A: 

Hi if you want to change the text of forms controls, you have to set the ForeColor property on all child controls, labels, checkboxes, textboxes, etc. individual. The forms ForeColor will only affect controls that are created after the forms forecolor was changed.

See this example: ForeColor.zip

Anders Eriksson
Oops Am using VS 2005.!!! :(
GIRISH GMAIL
+2  A: 

The title bar is a "non client" area of the form. Non-client area of the form is managed by windows API, and not by .NET. It cannot be changed by setting any property on a form. To change the color of the Title bar text, you would need to do custom painting. Search Google for terms like: non-client area painting winforms. You would need to make calls to the Win32 API directly for this to work. You can get some ideas from here: http://geekswithblogs.net/kobush/articles/CustomBorderForms.aspx and http://customerborderform.codeplex.com/wikipage?title=Painting%20NonClient%20Area&referringTitle=Home

It was easier to do back in the day (that is, when there was no .NET), since we directly used the Win32 API. I did it, for fun. And, I have since learned that such things are ok for learning; IMO I strongly recommend that you don't "misuse" this by putting it in a "real" application. Windows has a certain look and feel, and that look and feel should be under the user's control, not the developer's.

Liao