How to change the form border color c#?

后端 未结 5 2196
傲寒
傲寒 2020-12-06 06:54

I would like to change window form border color (the border with the form title). The example I found in codeplex is too much and confusing. Can any help me on something sim

相关标签:
5条回答
  • 2020-12-06 07:05

    Just follow these steps :

    • Set FormBorderStyle to None
    • Cover the form with a panel and leave some space for border
    • Set the color you want for the border as the form back color

    Now, the panel serves as the main container and you can change the background as you want and the form serves as the border !

    The Final Result :

    0 讨论(0)
  • 2020-12-06 07:09

    Unfortunately, since the form border is drawn by the Operating System, this is a complicated task. There is no real way around that.

    Do NOT click the ProjectDistributor link on the CodePlex page below

    The CodePlex Project for Drawing Custom Borders makes this very easy, though. Just build the form using SkinnedForm from that project instead of a standard Form, and it should work - you really don't need to do anything different in your code.

    0 讨论(0)
  • 2020-12-06 07:09

    Below "ForeColor" their should be a setting called "FormBorderStyle" You can edit it with that in VisualStudio 2015. Or you can go in control panel path should be something like this "Control Panel\Appearance and Personalization\Personalization" their will be a second setting called "Color" can change that to be what color you want it will change the color of the boarder in all of the programs to the color you set.

    0 讨论(0)
  • 2020-12-06 07:14

    Override it with:

    protected override void OnPaint(PaintEventArgs e)
    {
        ControlPaint.DrawBorder(e.Graphics, ClientRectangle, Color.[your_color], ButtonBorderStyle.Solid);
    }
    
    0 讨论(0)
  • 2020-12-06 07:24
    if (colorDialog1.ShowDialog() == DialogResult.OK)
    {
        string color = Convert.ToString(colorDialog1.Color);
        MessageBox.Show("You change the color " + color);
        this.BackColor = colorDialog1.Color; // BackColor is only accessible for this form
    }
    
    0 讨论(0)
提交回复
热议问题