Fonts and Labels in a Windows Form Messed Up?

  • Thread starter Christopher D. Wiederspan
  • Start date
C

Christopher D. Wiederspan

I'm converting a .NET 2.0 Beta project to the final version using Visual
Studio. In doing so, I've come across a strange problem with the fonts in my
labels. To see the problem, I have an empty form with 2 labels, one "Timing
Details:" and one "Package Details:" - each one Bolded. When viewing the
form in design mode within Visual Studio, everything looks good - as
expected. But when I run the form, the word "Details" in each of the two
labels looks different. The second one looks scrunched up.

Here's the guts of my form code - nothing out of the ordinary as far as I
can tell:

partial class Form1 {

private void InitializeComponent() {

this.packageDetailsGroupLabel = new System.Windows.Forms.Label();
this.timeDetailsGroupLabel = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// packageDetailsGroupLabel
//
this.packageDetailsGroupLabel.Font = new System.Drawing.Font("Microsoft
Sans Serif", 8.25F, System.Drawing.FontStyle.Bold,
System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.packageDetailsGroupLabel.Location = new System.Drawing.Point(12,
47);
this.packageDetailsGroupLabel.Name = "packageDetailsGroupLabel";
this.packageDetailsGroupLabel.Size = new System.Drawing.Size(163, 13);
this.packageDetailsGroupLabel.TabIndex = 22;
this.packageDetailsGroupLabel.Text = "Package Details:";
//
// timeDetailsGroupLabel
//
this.timeDetailsGroupLabel.Font = new System.Drawing.Font("Microsoft Sans
Serif", 8.25F, System.Drawing.FontStyle.Bold,
System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.timeDetailsGroupLabel.Location = new System.Drawing.Point(12, 9);
this.timeDetailsGroupLabel.Name = "timeDetailsGroupLabel";
this.timeDetailsGroupLabel.Size = new System.Drawing.Size(163, 13);
this.timeDetailsGroupLabel.TabIndex = 21;
this.timeDetailsGroupLabel.Text = "Timing Details:";
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(220, 79);
this.Controls.Add(this.packageDetailsGroupLabel);
this.Controls.Add(this.timeDetailsGroupLabel);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);

}

private System.Windows.Forms.Label packageDetailsGroupLabel;
private System.Windows.Forms.Label timeDetailsGroupLabel;
}


If you have any ideas, or would like to see a screenshot of what I'm talking
about, please let me know.

Thanks,
Chris
 
O

Onur \Xtro\ ER

Hi

I have the same problem with .net1.1

I know the reason of this error, but I cant solve it. I will tell you the
reason...

I dont know what xp skin style you use, But I use the best skin in the world
(most favoriated in art and desing web sites). Its name is "Sentinel" by a
man named "Chaninja"

This best looking skin has an error. I dont know how but some labels, or
butons or other controls can show missing words. I think it ocurs because of
getting wrong font length or height from skin.

I have 2 options for you and me but these are not good solutions

1) disable the visual style support for your program

or

2) set the main forms font property to your skins default font (you can see
it from desktop settings). if you do this option, you will see correct
labels and buttons. but, all ppl (using your program) will see your skin
font in their windows nomatter what default font is in their xp skin

example for option 2 :

My sentinel skin's default font is Thaoma. But I see default font property
is SansSerif in form designer. If I keep the default property and run the
program, I see missing words. ex : Buttons text = "Start (F9)" but I see
only "Start" on the button.

If I set the default font to Thaoma in form designer, I see correct labels.
ex : "Start (F9)"

But when someone use my program in his computer which has other type of skin
font, he will see thaoma fonted buttons and this is not good looking.
Different font window from the all other windows.


If we can set the form.font to skin's default font dynamicly in the starting
of the code, it could be fixed. But I dont know how to get the skin's
default font.

Sorry for my english but I tried the best to explain.

if you know how to get the skin's default font, pls let me know
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top