none
請教BindingSource事件(VB2005) RRS feed

  • 問題

  • BindingSource有一個PositionChanged 事件

    但好像沒有PositionChanging事件

    請問如果我想在Position變更之前做一些判斷應該要如何作

    謝謝

     

    2006年12月29日 上午 01:35

解答


  • Solution
    Basically the current version of .NET Framework does not allow you to break into
    the DataBinding layer to handle custom exceptions.  You need to validate the data
    before CurrencyManager calls EndEdit on your objects. Unfortunately, the
    CurrencyManager and BindingSource do not have PositionChanging or EndingCurrentEdit
    notifications.  Also, there is no entry point in the callstack (the one that you
    sent to us): all the methods are either internal or non-virtual (so the users can't
    override them to insert their own code).

    Meanwhile, one possible solution would be for you to handle Binding.Parse event and
    deal with incorrect data in the Binding.Parse event. The drawback for this is that
    you would have to do this for each simple bound control in your application.  You
    have stated that you will not be able to use this suggestion.  You have decided to
    take a hybrid approach (binding the grid, but not the simple controls) to get by
    this issue. 

    2007年1月15日 上午 10:27