Hallo Experten,
ich möchte gern ein unaufdringlich aufgepepptes Label. Fürs Erste soll es eine kleine Überschrift in der linken oberen Ecke haben. Dazu schrieb ich folgendes:
[highlight=c#]using System;
using System.Collections.Generic;
using System.Text;
namespace UCLib
{
public class CaptionedLabel:System.Windows.Forms.Label
{
#region Definitions
System.Windows.Forms.Label lbCaption = new System.Windows.Forms.Label();
#endregion
#region Properties
public string Caption
{
get { return (lbCaption.Text); }
set { lbCaption.Text = value; }
}
#endregion
#region Init
public CaptionedLabel()
{
this.Text = this.ToString();
this.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
lbCaption.Text = "Caption";
lbCaption.Location = new System.Drawing.Point(5, 0);
lbCaption.Font = new System.Drawing.Font(this.Font.FontFamily, 6.5f);
}
#endregion
}
}[/highlight]Das CaptionedLabel erscheint auch in der Toolbox der TestApplikation. Wenn ich aber eines auf die Form ziehe, geschieht gar nichts. Weder erscheint ein Label auf der Form noch eine Fehlermeldung auf dem Bildschirm.
Weiß jemand, wie ich das Label zu sehen bekomme?
Ciao,
luker
ich möchte gern ein unaufdringlich aufgepepptes Label. Fürs Erste soll es eine kleine Überschrift in der linken oberen Ecke haben. Dazu schrieb ich folgendes:
[highlight=c#]using System;
using System.Collections.Generic;
using System.Text;
namespace UCLib
{
public class CaptionedLabel:System.Windows.Forms.Label
{
#region Definitions
System.Windows.Forms.Label lbCaption = new System.Windows.Forms.Label();
#endregion
#region Properties
public string Caption
{
get { return (lbCaption.Text); }
set { lbCaption.Text = value; }
}
#endregion
#region Init
public CaptionedLabel()
{
this.Text = this.ToString();
this.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
lbCaption.Text = "Caption";
lbCaption.Location = new System.Drawing.Point(5, 0);
lbCaption.Font = new System.Drawing.Font(this.Font.FontFamily, 6.5f);
}
#endregion
}
}[/highlight]Das CaptionedLabel erscheint auch in der Toolbox der TestApplikation. Wenn ich aber eines auf die Form ziehe, geschieht gar nichts. Weder erscheint ein Label auf der Form noch eine Fehlermeldung auf dem Bildschirm.
Weiß jemand, wie ich das Label zu sehen bekomme?
Ciao,
luker
Comment