V
vuillet.thomas
Hi everybody !
I have a small strange problem and despite many tries, I can't find a
solution.
First, I'm using VS2005 with .NET CF 2.0.
I have an object which contains a public struct member. I want to bind
a property of this struct to a textbox on a a Form. After the bind, the
struct property is correctly displayed in the control but if I modify
the value in the textbox, I can see in debug that a struct's field is
updated, but it's not the one which I have in my object ! It's not easy
to explain like that, so here is some piece of code to reproduce :
// Here is a simple class which contains a public structure
public class MetierTest
{
public StructNature _objnature;
public MetierTest()
{
_objnature = new StructNature();
_objnature.Detail = "initvalue";
}
}
// Here is the struct definition
public struct StructNature
{
private string _detail;
public string Detail
{
get { return _detail; }
set { _detail = value; }
}
}
// Code used to bind the textbox to the "Detail" property of the
structure embedded in a MetierTest
// instance called _test
MetierTest _test = new MetierTest();
txtNatureDetail.DataBindings.Add("Text", _test._objnature, "Detail");
--> Result :
- "initvalue" is displayed in the textbox
- when modifying the textbox content and validate it, "set" of "Detail"
property in StrucNature is executed and the new value is set
- BUT _test._objnature.Detail is still equals to "initvalue" !
If I use a class instead of StructNature, it works but I would prefer
to use structures beacuse of perfomance reasons (there will be no
methods in this class, only properties).
Thank you for reading and for your help !
Bye,
Thomas.
I have a small strange problem and despite many tries, I can't find a
solution.
First, I'm using VS2005 with .NET CF 2.0.
I have an object which contains a public struct member. I want to bind
a property of this struct to a textbox on a a Form. After the bind, the
struct property is correctly displayed in the control but if I modify
the value in the textbox, I can see in debug that a struct's field is
updated, but it's not the one which I have in my object ! It's not easy
to explain like that, so here is some piece of code to reproduce :
// Here is a simple class which contains a public structure
public class MetierTest
{
public StructNature _objnature;
public MetierTest()
{
_objnature = new StructNature();
_objnature.Detail = "initvalue";
}
}
// Here is the struct definition
public struct StructNature
{
private string _detail;
public string Detail
{
get { return _detail; }
set { _detail = value; }
}
}
// Code used to bind the textbox to the "Detail" property of the
structure embedded in a MetierTest
// instance called _test
MetierTest _test = new MetierTest();
txtNatureDetail.DataBindings.Add("Text", _test._objnature, "Detail");
--> Result :
- "initvalue" is displayed in the textbox
- when modifying the textbox content and validate it, "set" of "Detail"
property in StrucNature is executed and the new value is set
- BUT _test._objnature.Detail is still equals to "initvalue" !
If I use a class instead of StructNature, it works but I would prefer
to use structures beacuse of perfomance reasons (there will be no
methods in this class, only properties).
Thank you for reading and for your help !
Bye,
Thomas.