How to add event to some fields to respond to one method?


Author
Message
Edhy Rijo
E
StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi All,

I have a form with some fields including address fields.  There is one field FormattedAddress which I have to update with some fields concatenated for an address label.

What would be the best way to address this kind of situation?

So far I am testing in the BO_FieldPropertyChanged event, but I then have to filter this event for the list of fields that will participate in the concatenation format.  Just wondering if I am in the correct place or there is any other way to do this?

Thanks!

Edhy Rijo

Replies
Peter Jones
Peter Jones
Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)
Group: Forum Members
Posts: 386, Visits: 2.1K
Hi,

Check the topic "Adding Custom Field Properties" in the SF help - the example is exactly (I think) along the lines of what you are looking to do.

I presume you are not trying to concatinate these columns together and actually storing the info into another column. If you are then it is best that you don't - just create the address label data on the fly as you need it, either in a custom field like the example of in a proc that returns the data for the label.

Cheers, Peter

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
Pete is right on the money, create a custom property that does the work for you.  You can then use this property from anywhere in your application and even bind to it.  This is how we do it ourselves. 

Public Readonly Property FormattedAddress As String
    Get
      '-- Establish Locals
     Dim r As String

     r = AddressLine1 & COntrolChars.CrLf & City & ", " & State & "  " & Zip

     '-- Return formatted address
     Return r
    End Get
End Property

You can get the property attributes from another property on your bo out of the partial class.  You can also copy the Imports out of the header of the partial class for the BO as well to make some of those errors go away.  Once you do this, if you intend to bind to the property then you will need to override the GetCustomBindablePropertyDescriptors method (which you can find in the help and samples....or by doing a search out here on the forum...lots of posts Smile)

Edhy Rijo
E
StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi Peter, Trent,

Thanks for the suggestions, but I actually need to have this value stored in the database because it will be use from many forms to print receipts, labels and reports.

This is what I have done in the BO:

Private Sub ProducerBO_FieldPropertyChanged(ByVal sender As Object, ByVal e As ProducerBOFieldChangedEventArgs) Handles Me.FieldPropertyChanged

     If e.FieldChanged = ProducerBOFieldNames.ProducerName Or ProducerBOFieldNames.Street _

          Or ProducerBOFieldNames.City Or ProducerBOFieldNames.State _

          Or ProducerBOFieldNames.Zip Or ProducerBOFieldNames.Phone _

          Or ProducerBOFieldNames.Fax Or ProducerBOFieldNames.EmailAddress Then

          ' Format the Full Address string

          Dim cFullAddress As StringBuilder = New StringBuilder

          cFullAddress.AppendLine(Me.ProducerName)

          cFullAddress.Append(Me.Street)

          cFullAddress.Append(" " & Me.City)

          cFullAddress.Append(" " & Me.State)

          cFullAddress.AppendLine(" " & Me.Zip)

          cFullAddress.AppendLine(" Phone " & Me.Phone & " Fax " & Me.Fax)

          cFullAddress.Append(Me.EmailAddress)

          Me.FullAddress = cFullAddress.ToString

     End If

End Sub

The format of the address is working fine, but I want to limit this code to only execute for the fields included in the IF.. condition, but it is not working.  If anybody can see what I am doing wrong please let me know.

Thanks!

Edhy Rijo

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Threaded View
Threaded View
Edhy Rijo - 17 Years Ago
Peter Jones - 17 Years Ago
Trent L. Taylor - 17 Years Ago
Edhy Rijo - 17 Years Ago
Peter Jones - 17 Years Ago
Trent L. Taylor - 17 Years Ago
Edhy Rijo - 17 Years Ago
Greg McGuffey - 17 Years Ago
Edhy Rijo - 17 Years Ago
Trent L. Taylor - 17 Years Ago
                         Edhy,

Just offering some options. You never know when...
Greg McGuffey - 17 Years Ago
                             All good advice, Greg. I will warn you, though, that the larger your...
Trent L. Taylor - 17 Years Ago
                                 Hmmmm...good info Trent. The tables I'm using this on are small and...
Greg McGuffey - 17 Years Ago
                                     LOL....thanks, Greg! I always truly appreciate your contributions out...
Trent L. Taylor - 17 Years Ago

Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search