views:

217

answers:

0

I've created a Form using DevExpress' BarManager and PanelControl. Inside the Panel Control is a XTraTabControl that in turn contains a TextEdit. This textbox is bound to a list of Individuals' name.

In the BarManager, I have two buttons Previous and Next. They are used to increment or decrement the BindingManager's position.

My problem is that when I click either Previous or Next Button, it executes the handler methods first before binding the changed value of the textbox into the Individual object. This is in contrast to normal behavior of a simple button that is located inside the PanelControl that first resolves the binding, then executes the method handler.

I'm guessing the BarManager doesn't see the items inside the PanelControl and so doesn't resolve them first. Would anybody know of a way to force the resolution of the binding first before execution of the method?

mports System.Text

Public Class Form1

    Private _personList As List(Of Individual)

    Private _bindingManager As BindingManagerBase

    Private Shared _callTrace As New StringBuilder

    Public Shared Property CallTrace() As StringBuilder
        Get
            Return _callTrace
        End Get
        Set(ByVal value As StringBuilder)
            _callTrace = value
        End Set
    End Property

    Public Sub New()

        ' This call is required by the Windows Form Designer.
        InitializeComponent()

        ' Add any initialization after the InitializeComponent() call.

        _personList = New List(Of Individual)

        _personList.Add(New Individual With {.Name = "Person1"})
        _personList.Add(New Individual With {.Name = "Person2"})
        _personList.Add(New Individual With {.Name = "Person3"})
        _personList.Add(New Individual With {.Name = "Person4"})

        _bindingManager = BindingContext(_personList)

        TextEdit1.DataBindings.Add(New Binding("Text", _personList, "Name"))
        TextEdit1.Text = "Hello"

    End Sub

    Public Overrides Property BindingContext() As BindingContext
        Get
            Return MyBase.BindingContext
        End Get
        Set(ByVal value As BindingContext)
            MyBase.BindingContext = value
        End Set
    End Property

    Public Class Individual

        Private _name As String

        Public Property Name() As String
            Get
                Return _name
            End Get
            Set(ByVal value As String)
                _name = value
            End Set
        End Property

    End Class

    Private Sub NextButton_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles NextButton.ItemClick
        _bindingManager.Position += 1
    End Sub

    Private Sub PreviousButton_ItemClick(ByVal sender As System.Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles PreviousButton.ItemClick
        _bindingManager.Position -= 1
    End Sub
End Class