Trying to get a Label's text propery exposed
I have the following code in one of my Base forms:
using System;
using System.Drawing;
using Telerik.WinControls.UI;
namespace ExciteEngine2.MainApplication.BaseUI {
public partial class BaseCreateForm : BaseForm {
public BaseCreateForm() {
InitializeComponent();
SetupLookAndFeelThings();
Header = Tag.ToString();
}
public void SetupLookAndFeelThings() {
LabelHeader.Font = new Font(Font.FontFamily, 14.25F, Font.Style, Font.Unit, Font.GdiCharSet);
}
protected RadLabel HeaderLabel {
get {
return LabelHeader;
}
set {
LabelHeader = value;
}
}
protected String Header {
get {
return LabelHeader.Text;
}
set {
LabelHeader.Text = value;
}
}
开发者_StackOverflow
protected Image HeaderImage {
get {
return LabelHeader.Image;
}
set {
LabelHeader.Image = value;
}
}
private void RadButtonCancel_Click(object sender, EventArgs e) {
Close();
}
}
}
So, I have a couple of properties that allow me to setup Titles and subtitles. But these properties are not visible in the inheriting form's visual designer property grid. I really need to set the base label's image, for example. What can I do to get these properties into the Property grid?
Okay, after much Google, I came up with this:
using System;
using System.ComponentModel;
using System.Drawing;
namespace ExciteEngine2.MainApplication.BaseUI {
public partial class BaseCreateForm : BaseForm {
public BaseCreateForm() {
InitializeComponent();
SetupLookAndFeelThings();
}
public void SetupLookAndFeelThings() {
LabelHeader.Font = new Font(Font.FontFamily, 12.25F, Font.Style, Font.Unit, Font.GdiCharSet);
}
[Category("Appearance"), DisplayName("HeaderText"), DescriptionAttribute("Text of the form's header."), Browsable(true)]
public String HeaderText {
get {
return LabelHeader.Text;
}
set {
LabelHeader.Text = value;
}
}
[Category("Appearance"), DisplayName("HeaderImage"), DescriptionAttribute("Image of the form's header."), Browsable(true)]
public Image HeaderImage {
get {
return PictureTitle.Image;
}
set {
PictureTitle.Image = value;
}
}
private void RadButtonCancel_Click(object sender, EventArgs e) {
Close();
}
}
}
Had to add those Attributes from the ComponentModel.
精彩评论