How can I add an Items-like property to my User Control?

Posted by Dan Tao on Stack Overflow See other posts from Stack Overflow or by Dan Tao
Published on 2010-04-22T01:07:09Z Indexed on 2010/04/22 1:13 UTC
Read the original article Hit count: 336

Filed under:
|
|
|
|

It's pretty straightforward to add simple properties to a User Control that will appear in the desired categories in the Windows Forms designer, e.g.:

[Category("Appearance")]
public Color BackColor {
    get { return _textBox.BackColor; }
    set { _textBox.BackColor = value; }
}

What if I want to expose a more complex property, such as a collection of items of a type I define? I'm thinking something along the lines of the ListView.Items property, or the DataGridView.Columns property -- where the user of the control can access this complex property via a more specialized pop-up form (as opposed to a simple TextBox or ComboBox).

Even a simple nudge in the right direction would be much appreciated.

© Stack Overflow or respective owner

Related posts about .NET

Related posts about usercontrols