Hi all,
Tearing my hair out on this one so hopefully somebody can help.
I have written a custom control to represent a button on a touchscreen EPoS
(electronic point of sale) peice of hardware. As part of my control I have
a property declared like so:
private byte posForeColor;
/// <summary>
/// Gets/Sets the byte that represents the foreground color for the PoS
hardware
/// </summary>
[Browsable(true) ,Category("Appe arance"),Descri ption("Gets/Sets the value of
the foreground color for the PoS hardware")]
public byte PosForeColor
{
get{return posForeColor;}
set
{
//set the private var.
posForeColor = value;
//Calculate actual windows colour to display on control.
convertor.Set(v alue);
ForeColor = convertor.ToSta ndardColor();
}
}
Just in case you wondered, the hardware stores it's colors as a single byte
(3 bits red, 3 bits Green, 2 bits Blue). I have an App that uses my custom
control, as well as a DataGrid that displays other information in the table
I am interested in. I have created the binding for my control like this:
//Sample pos button
Binding buttonFCBinding = new Binding("PosFor eColor",tblCons olidated,"FG");
//parseByteToStri ng takes the byte value from the control, and changes it to
the string hex representation stored in the Pos' xml file.
buttonFCBinding .Parse += new ConvertEventHan dler(parseByteT oString);
//formatStringToB yte takes a string representation of the colour byte (in
hex) from the Pos' xml file and changes it to an actual byte for the control
buttonFCBinding .Format += new ConvertEventHan dler(formatStri ngToByte);
//Add the binding
btnSample.DataB indings.Add(but tonFCBinding);
So far, so good. The the binding works fine, and as I scroll through my
data grid, the control changes appearance accordingly. Excellent!
When I am done with this screen I make a call to:
tblConsolidated .GetChanges(Dat aRowState.Modif ied)
My problem is that any row I have navigated to, returns itself as modified -
even if I havent changed a thing! I know it has something to do with my
control/property because if I bind something to lets say "Text" for example,
I dont get this behaviour. It is only when I bind to my own properties.
Does anybody know what is wrong. Am I missing an attribute or something.
Any help would greatly be appreciated.
Thanks,
Simon.