N
Norm Dotti
I have a user control that I drop to windows forms. I also
have typed dataset that is defined in the windows form
project. I want to bind the textboxes within the
usercontrol to a datatable field in this typed dataset.
I found the following old posting on this issue. But what
happens is, this property is not written to codebehind of
the form if it's set. So when I run the program it clears
the binding info. What do I have to do to make this work?
/*
Hello Colin,
You can export the DataBindings property of the child
control via property.
Since the DataBindings property is read only, you may need
to write some
code to handle set method of the property. This is a
sample code:
public System.Windows.Forms.ControlBindingsCollection
textBindings
{
set
{
System.Windows.Forms.ControlBindingsCollection bindings;
bindings =
(System.Windows.Forms.ControlBindingsCollection)value;
textBox1.DataBindings.Clear();
foreach(Binding b in bindings)
textBox1.DataBindings.Add(b);
}
get
{
return textBox1.DataBindings;
}
}
Hope it helps.
Best regards,
Lion Shi, MCSE, MCSD
Microsoft Support Engineer
This posting is provided "AS IS" with no warranties, and
confers no rights.
You assume all risk for your use. 2001 Microsoft
Corporation. All rights
reserved.
*/
Thanks
have typed dataset that is defined in the windows form
project. I want to bind the textboxes within the
usercontrol to a datatable field in this typed dataset.
I found the following old posting on this issue. But what
happens is, this property is not written to codebehind of
the form if it's set. So when I run the program it clears
the binding info. What do I have to do to make this work?
/*
Hello Colin,
You can export the DataBindings property of the child
control via property.
Since the DataBindings property is read only, you may need
to write some
code to handle set method of the property. This is a
sample code:
public System.Windows.Forms.ControlBindingsCollection
textBindings
{
set
{
System.Windows.Forms.ControlBindingsCollection bindings;
bindings =
(System.Windows.Forms.ControlBindingsCollection)value;
textBox1.DataBindings.Clear();
foreach(Binding b in bindings)
textBox1.DataBindings.Add(b);
}
get
{
return textBox1.DataBindings;
}
}
Hope it helps.
Best regards,
Lion Shi, MCSE, MCSD
Microsoft Support Engineer
This posting is provided "AS IS" with no warranties, and
confers no rights.
You assume all risk for your use. 2001 Microsoft
Corporation. All rights
reserved.
*/
Thanks