I cant remember all the details, but in your case you want to set a property
on a control that is not added to the design surface, this is because its
contained (and pretty much hidden) by your UserControl.
You can solve this in two ways AFAIK.
The easiest is that instead of exposing the TextBox you create a property in
the UserControl that exposes the property of the TextBox. Ie, InnerTag which
simply uses the TextBox's Tag as the datastore. Tag that as <DataBindable>
and it *should* work. I didnt test it though so I might have forgotten some
detail..
The other way to solve it would be to read the following article which
teaches you how to create a container control, its a bit overkill the way he
does it as he provides a way to add controls (a colored box in the example)
but I think you can use a subset of the code to get it to work in your case.
Point being, you need to add your textbox as a control to the designsurface
to be able to bind it properly to the dataset.
http://www.divil.co.uk/net/articles/designers/collectioncontrols.asp
Id recomend the first version in this case, but the tutorial is a good read
anyways
Hope it helps
/Dan
> Hi everybody,
>
[quoted text clipped - 37 lines]
>
> Arthur
Arthur - 06 Apr 2004 08:27 GMT
Thank you, Dan, for your answer. I'll definitely go through the article
you've pointed to because it seems to be very interesting.
In the meantime I've completed a lot of experiments and it seems that there
is no one-step way to go.
The simplest solution I've found till now is like this:
1) I need a custom converter class that derives from the ComponentConverter:
public class MyConverter : System.ComponentModel.ComponentConverter
{
public override bool CanConvertTo(...)
{
// return true for the MyType destination type
}
public override object ConvertTo(...)
{
// return an empty string for the String destination type and value
of the MyType type
}
}
2) I need a custom type class that exposes the DataBindings collection and
is maintained by the converter. The DataBindings property shold be
persistent.
[TypeConverter(typeof(MyConvereter))]
public class MyType
{
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public ControlBindingsCollection DataBindings
{
get {return innerTextBox.DataBindings;
}
}
3) The parent user control should exposes a property of the MyType type. It
should be also persistent.
public class MyControl : System.Windows.Forms.UserControl
{
private MyType myProperty;
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public MyType MyProperty
{
get {return myProperty;}
}
}
Maybe this can be helpful also for others.
Arthur
> I cant remember all the details, but in your case you want to set a property
> on a control that is not added to the design surface, this is because its
[quoted text clipped - 68 lines]
> >
> > Arthur