AcceptButton like property

I'd like to add a "Target" property to my UserControl that lists all textboxes on a form and allows me to pick up one and assign it to that property.
Something similar to Form's AcceptButton property that list all buttons available on container form.
Any hint?

TIA
Corrado

[289 byte] By [CorradoCavalli] at [2007-12-16]
# 1
Hi,

Make your property of the type of the control you want to be listed on your propertygrid. On your case, you can do it this way:

private TextBox _myTextBox = null;

[ DefaultValue(null) ]
public TextBox MyTextBox
{
get { return _myTextBox; }
set { _myTextBox = value; }
}

The attribute above the property indicates that you want your property to able to remove (or accept null) value.
-chris

gwapo at 2007-9-9 > top of Msdn Tech,Windows Forms,Windows Forms Designer...
# 2

Thanks, but is not what I'm looking form.
I'm not trying to expose a Textbox from my control, i want my control to list all textboxes available on the same form where my control sites.
So i presume I have to use Parent property and enumerate all textboxes in parent.Controls, but don't know if this is the right choice.
FYI: Default value does not indicates what type your property accepts but just its default value and how it should be serialized...

Thanks, anyway
Corrado

CorradoCavalli at 2007-9-9 > top of Msdn Tech,Windows Forms,Windows Forms Designer...
# 3
Corrado Cavalli wrote:
FYI: Default value does not indicates what type your property accepts but just its default value and how it should be serialized...

Hi corrado,

Thanks for the correction. I actually want to say the same thing, but I find it difficult sometimes to speak in a foreign language like the language of this forum which is "english". I think I have to workout with my english more.

Thanks again.

-chris

gwapo at 2007-9-9 > top of Msdn Tech,Windows Forms,Windows Forms Designer...