I also tried adding a custom column in the BO that returns a TimeSpan, but in addition to not formatting the value the way I want to (showing exactly hundredths of a second), I it doesn't post the changed value back to the table via the BO property's set.
Any suggestions?
...Jim
More than likely you will want to use a masked text box if you are going to allow user input. Otherwise, just use the BindingFormat property of the text box. This allows you to use the same formatting as a String.Format() command ({0}, {1}, etc). You could also create a custom control and implement our data binding as well.
It will if you set a property that is to be propogated back to the server within the Set event of your custom property. You have to do something with the data when the Set is fired within the property. Generally this means that you have to parse the data and set the strong-typed properties that will be saved back to the server.
Thanks for the rapid reply.
I can't see where a MaskedTextBox is any help. There are only 60 seconds in a minute and only 60 minutes in an hour, so arithmatic must be done, not just formatting.
I might try creating a custom control, but that sounds like more work than if I can get something working with the set property. Actually I have a custom class for the type that does the parsing and formatting, so that would be easy.
I have a set for the BO property used as a calculated column, but when I set a breakpoint in it, it never hits the breakpoint. Is there something else that I need to do?
If you want to edit the exact value rather than formatting it as a string and then parsing, you are going to have to create a custom control.
You are correct...but you can reverse engineer it to place it back into a date time if you need to. If you know the starting DateTime then you can always get back to a date time by just doing the math.
I would have to see how your custom property was created, but if you properly implement a custom property with the same attributes as a property created through the BO mapper then a control does not know the difference when bound.
First, my custom class for centi-seconds that already did the parsing and formatting worked great, but to use it as the type of the BO property for the custom column I first had to create a custom TypeConverter to go with it (easy!). But that still didn't get it working.
The second piece to the puzzle was the same reason that the TimeSpan didn't work: I have to have formattingEnabled set to true in the binding object. Ergo, I had to set BindingFormat to something on the control so StrataFrame would set formattingEnabled to true. That done, my set on the BO property gets called just fine! Why the binding object needs to have formattingEnabled set to true for TimeSpan and my custom type, but not for double is beyond me!