B
Brian Pelton
I am trying to bind a textbox to the property of a property.
This code works when nested property is not null,
but it fails when nested is null.
(It fails when SiteLine.Site is null.)
The error is ArgumentNullException: component.
I setup the binding in the constructor of my Form.
_chemicalRecsDBS is bound to an IList<ChemicalRec>.
Here are the relevant class definitions:
This code works when nested property is not null,
but it fails when nested is null.
(It fails when SiteLine.Site is null.)
The error is ArgumentNullException: component.
I setup the binding in the constructor of my Form.
Code:
txtAcres.DataBindings.Add("Text", _chemicalRecsDBS,
"SiteLine.Site.CropAcres", true);
txtAcres.DataBindings["Text"].Format += new
ConvertEventHandler(Lib.AppCommon.DataBinding.IntFormatHandler);
txtAcres.DataBindings["Text"].Parse += new
ConvertEventHandler(Lib.AppCommon.DataBinding.IntParseHandler);
txtAcres.DataBindings["Text"].NullValue = null;
_chemicalRecsDBS is bound to an IList<ChemicalRec>.
Here are the relevant class definitions:
Code:
Class ChemicalRec
{
public ChemicalRecSite SiteLine
{
get { ... }
set { ... }
}
}
Class ChemicalRecSite
{
public SiteInfo Site
{
get { ... }
set { ... }
}
}
Class SiteInfo
{
public int? CropAcres
{
get { ... }
set { ... }
}
}