Попытка раскрыть текст Label надлежащим образом - PullRequest
0 голосов
/ 02 февраля 2011

У меня есть следующий код в одной из моих базовых форм:

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;
      }
    }

    protected Image HeaderImage { 
      get {
        return LabelHeader.Image;
    } 
      set {
        LabelHeader.Image = value;
    } 
    }

    private void RadButtonCancel_Click(object sender, EventArgs e) {
      Close();
    }

  }
}

Итак, у меня есть пара свойств, которые позволяют мне устанавливать заголовки и субтитры.Но эти свойства не видны в сетке свойств визуального конструктора наследуемой формы.Мне действительно нужно установить изображение базовой метки, например.Что я могу сделать, чтобы получить эти свойства в сетке свойств?

1 Ответ

0 голосов
/ 08 февраля 2011

Хорошо, после большого количества Google, я придумал это:

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();
    }

  }
}

Пришлось добавить эти атрибуты из ComponentModel.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...