center form title c# code example

Example: how to center align the title bar text in windows form

//Title bar button icons on normal state
this.Style.TitleBar.CloseButtonImage = Image.FromFile("close.ico");
this.Style.TitleBar.MaximizeButtonImage = Image.FromFile("max.ico");
this.Style.TitleBar.MinimizeButtonImage = Image.FromFile("min.ico");

//Title bar button icons on hover state
this.Style.TitleBar.CloseButtonHoverImage = Image.FromFile("hoverClose.ico");
this.Style.TitleBar.MaximizeButtonHoverImage = Image.FromFile("hoverMax.ico");
this.Style.TitleBar.MinimizeButtonHoverImage = Image.FromFile("hoverMin.ico");

//Title bar button icons on pressed state
this.Style.TitleBar.CloseButtonPressedImage = Image.FromFile("pressedClose.ico");
this.Style.TitleBar.MaximizeButtonPressedImage = Image.FromFile("pressedMax.ico");
this.Style.TitleBar.MinimizeButtonPressedImage = Image.FromFile("pressedMin.ico");

Tags:

Misc Example