Notify to show error


Author
Message
Chan
Chan
Advanced StrataFrame User (723 reputation)Advanced StrataFrame User (723 reputation)Advanced StrataFrame User (723 reputation)Advanced StrataFrame User (723 reputation)Advanced StrataFrame User (723 reputation)Advanced StrataFrame User (723 reputation)Advanced StrataFrame User (723 reputation)Advanced StrataFrame User (723 reputation)Advanced StrataFrame User (723 reputation)
Group: Forum Members
Posts: 533, Visits: 2K
Hi,

I would like to raise "exception" in Property Setter method. For example, upon user specify value to textbox and updated to field property, my program will check for some logic, if not valid, I want to show error provider icon immediately instead of waiting Save().



I tried to add broken rules, but it doesn't reflect the UI.



How to raise the "event" so that error provider icon will be shown?



Thank you
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
You would have to handle an event or add the logic to the Set method of the property.  This may be a good place for you to use the INotifyPropertyChanged event.

Public Class MyClass
    Implements System.ComponentModel.INotifyPropertyChanged

    Public Event PropertyChanged(ByVal sender As Object, ByVal e As System.ComponentModel.PropertyChangedEventArgs) Implements System.ComponentModel.INotifyPropertyChanged.PropertyChanged


    Public Property MyProperty As String
        Get
            Return _MyProperty
        End Get
        Set(Byval value as String)
            _MyProperty = value
            Raiseevent PropertyChanged(Me,New System.ComponentModel.PropertyChangedEventArgs("MyProperty"))
        End Set
    End Property

End Class

There are some other ways to go about it as well, but you will have to take action on the setting of the property.  If you want to use the BO mapper to do this for you, then use the PropertyChanging or PropertyChanged events.


StrataFrame Team
S
StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
Most grids have a DataError event that will be raised when an exception occurs.  The grid will trap the exception and raise the event and pass the exception through the event args.  This would allow you to show a message box or set the text on a label somewhere that would indicate the error to the user.  However, as I mentioned in your other post about this similar matter, you'll need to add the broken rules to the BBS.BusinessObject reference for the ErrorProvider to pick up the error and display it.
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