Custom Format/Parse


Author
Message
Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
I'm glad that you got it going Smile 
James H Hansen
James H Hansen
StrataFrame Beginner (29 reputation)StrataFrame Beginner (29 reputation)StrataFrame Beginner (29 reputation)StrataFrame Beginner (29 reputation)StrataFrame Beginner (29 reputation)StrataFrame Beginner (29 reputation)StrataFrame Beginner (29 reputation)StrataFrame Beginner (29 reputation)StrataFrame Beginner (29 reputation)
Group: Forum Members
Posts: 11, Visits: 57
Thanks for trying to help, Trent.  Your assurance kept me looking and I figured it out with the help of some previous postings on newsgroups.  Hang on to your hat:

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 meCrazy!

Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
so arithmatic must be done,

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.

The problem is that TimeSpan doesn't do formatting like DateTime.

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 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?

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.

James H Hansen
James H Hansen
StrataFrame Beginner (29 reputation)StrataFrame Beginner (29 reputation)StrataFrame Beginner (29 reputation)StrataFrame Beginner (29 reputation)StrataFrame Beginner (29 reputation)StrataFrame Beginner (29 reputation)StrataFrame Beginner (29 reputation)StrataFrame Beginner (29 reputation)StrataFrame Beginner (29 reputation)
Group: Forum Members
Posts: 11, Visits: 57
Oh! I misunderstood the thing about the BindingFormat.  The problem is that TimeSpan doesn't do formatting like DateTime.

...Jim

James H Hansen
James H Hansen
StrataFrame Beginner (29 reputation)StrataFrame Beginner (29 reputation)StrataFrame Beginner (29 reputation)StrataFrame Beginner (29 reputation)StrataFrame Beginner (29 reputation)StrataFrame Beginner (29 reputation)StrataFrame Beginner (29 reputation)StrataFrame Beginner (29 reputation)StrataFrame Beginner (29 reputation)
Group: Forum Members
Posts: 11, Visits: 57
Trent,

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?

...Jim

Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
I've done this before by using the Format and Parse events of the control's binding, but I can't figure out how to do that with StrataFrame.

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.

I it doesn't post the changed value back to the table via the BO property's set.

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. 

James H Hansen
James H Hansen
StrataFrame Beginner (29 reputation)StrataFrame Beginner (29 reputation)StrataFrame Beginner (29 reputation)StrataFrame Beginner (29 reputation)StrataFrame Beginner (29 reputation)StrataFrame Beginner (29 reputation)StrataFrame Beginner (29 reputation)StrataFrame Beginner (29 reputation)StrataFrame Beginner (29 reputation)
Group: Forum Members
Posts: 11, Visits: 57
I am trying to complete a test of StrataFrame before my trial runs out on Thursday.  One of the tasks is to create a data entry form where one of the controls displays an enters values from a column that is in centi-seconds in a format like "1:30:22.55".   I've done this before by using the Format and Parse events of the control's binding, but I can't figure out how to do that with StrataFrame.

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

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search