I am writing an application under Compact Framework 3.5. Created your component by inheriting it from Label. The main change is the auto-height label. There is no AutoSize in the compact framework.

public partial class AutoSizeLabel2 : Label { static Bitmap bmpSizer = new Bitmap(10, 10); static Graphics g = Graphics.FromImage(bmpSizer); public AutoSizeLabel2() { this.Text = "Label"; } public override string Text { get { return this.Text; } set { Rectangle clientRec = this.ClientRectangle; clientRec.Inflate(-2, 0); this.Height = CFMeasureString.MeasureString(g, value, clientRec, false).Height; this.Text = value; this.Invalidate(); } } } 

But when working with a component in the form designer, instead of a specified text, WMS_Project.AutoSizeLabel2 is always reflected. An example in the attached file. Example

  • one
    Most likely, the OnTextChaged event is simply not triggered. Try calling base.Text . not this.Text . this.Text . - Jester
  • It is not drawn exactly in Design Time in the constructor. When you start the application, everything is more or less normal. Only at the first assignment for some reason only half of the height is drawn, in subsequent times everything is worked out correctly. I didn’t change anything - alexfess

0