I am trying to create a custom title bar for my form. For this reason I have:
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
I've positioned two custom buttons for minimising and closing as such:
// Close
//
this.Close.BackColor = System.Drawing.Color.Black;
this.Close.FlatAppearance.BorderColor = System.Drawing.Color.White;
this.Close.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.Close.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.Close.ForeColor = System.Drawing.SystemColors.ButtonFace;
this.Close.Location = new System.Drawing.Point(376, 0);
this.Close.Name = "Close";
this.Close.Size = new System.Drawing.Size(27, 23);
this.Close.TabIndex = 1;
this.Close.Text = "X";
this.Close.UseVisualStyleBackColor = false;
this.Close.Click += new System.EventHandler(this.Close_Click);
//
// Hide
//
this.Hide.BackColor = System.Drawing.SystemColors.ControlText;
this.Hide.FlatAppearance.BorderColor = System.Drawing.Color.White;
this.Hide.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.Hide.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.Hide.ForeColor = System.Drawing.SystemColors.ButtonFace;
this.Hide.Location = new System.Drawing.Point(346, 0);
this.Hide.Name = "Hide";
this.Hide.Size = new System.Drawing.Size(30, 23);
this.Hide.TabIndex = 0;
this.Hide.Text = "---";
this.Hide.UseVisualStyleBackColor = true;
Which Is meant to look like this:
However, for some reason when I run the app they appear like this (without the text):
Also, I've coded it so that upon clicking the Close button this code is run:
private void Close_Click(object sender, EventArgs e)
{
this.Close();
}
However, when I click close nothing happens.
Can anybody point as to what is wrong with my code. Or what I have to add to fix it.
Edit:
Turns out, when I change the button colour to red the cross shows, but it is black, not white!
Aucun commentaire:
Enregistrer un commentaire