Ticket T160334
Visible to All Users

How to change title bar color programmatically?

created 10 years ago

[DevExpress Support Team: CLONED FROM K18374: How to change one skin element in all available skins]
Looking at above example
if I am not mistaken, to change only title bar color I should be able to do it programmatically for any skin using
SkinElement element = currentSkin[skinElementName];
.
.
It would be of great help if you could provide code snippet which will change form title bar back color to, for example, black (the same color as "hybridapp" is using)

Answers approved by DevExpress Support

created 10 years ago (modified 10 years ago)

Hi Zeljko,
You're right, it's possible to change any skin element programmatically, so all your modifications will be applied throughout our skins collection. Here is the required code for the SkinFormCaption element:

C#
protected override void OnShown(EventArgs e) { base.OnShown(e); Skin currentSkin = FormSkins.GetSkin(this.LookAndFeel); SkinElement element = currentSkin[FormSkins.SkinFormCaption]; element.Image.Image = null; element.Color.BackColor = Color.Red; element.Color.BackColor2 = Color.Green; this.LookAndFeel.UpdateStyleSettings(); }

Take special note that I'm setting skin element's Image to null. Otherwise, my custom appearance settings will be not taken into account since everything will be painted as a custom bitmap.
Try this solution and let me know if it works for you.

    Show previous comments (11)
    DevExpress Support Team 10 years ago

      Hello,

      I am happy to hear that my assistance was helpful to you. Feel free to contact us if you have additional questions.

        hi :
        thanks for your help.
        I have a question:
        In the above case, all the form styles in the program have been changed after I applied the LookAndFeel.UpdateStyleSettings() method.I don't want this.
        I just want to change the form caption background color in a specific form (such as login form).
        In order to achieve this effect, I temporarily set FormBorderStyle = FormBorderStyle.None, but this is obviously not the final solution. is there any other way? thank you.

        I look forward to your reply
        Best regards.

        DevExpress Support Team 4 years ago

          Hello,

          I created a separate ticket on your behalf: T1023630: How to change the appearance for only specific form. We placed it in our processing queue and will process it shortly.

          Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

          Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.