Disable Infragistics Toolbar Button (ButtonTool)
I need to Enable/Disable the ButtonTool.
Before using Infragistics I used an ordinaly WinForms ToolbarButton, that have a property "Enabled".
I used the da开发者_如何学运维tabinding like this:
UndoButtonTool.DataBindings.Clear()
UndoButtonTool.DataBindings.Add("Enabled", memory, "CanUndo")
How can I do now using the infragistics ButtonTool?
doing
UndoButtonTool.DataBindings.Clear()
UndoButtonTool.DataBindings.Add("SharedProps.Enabled", memory, "CanUndo")
will not work...
I already implemented an custom BindableButtonTool:
Public Class ToolStripBindableButton
Inherits Infragistics.Win.UltraWinToolbars.ButtonTool
Implements IBindableComponent
Private _DataBindings As ControlBindingsCollection
Private _BindingContext As BindingContext
Private _Site As System.ComponentModel.ISite
Public Event DisposedAsStrip As EventHandler Implements IBindableComponent.Disposed
Sub New(ByVal name As String)
MyBase.New(name)
End Sub
Public ReadOnly Property DataBindings() As ControlBindingsCollection Implements System.Windows.Forms.IBindableComponent.DataBindings
Get
If _DataBindings Is Nothing Then
_DataBindings = New ControlBindingsCollection(Me)
End If
Return _DataBindings
End Get
End Property
Public Property BindingContext() As BindingContext Implements System.Windows.Forms.IBindableComponent.BindingContext
Get
If _BindingContext Is Nothing Then
_BindingContext = New BindingContext()
End If
Return _BindingContext
End Get
Set(ByVal value As BindingContext)
_BindingContext = value
End Set
End Property
Public Overloads Sub Dispose()
If _DataBindings IsNot Nothing Then
_DataBindings.Clear()
_DataBindings = Nothing
End If
_BindingContext = Nothing
MyBase.Dispose()
RaiseEvent DisposedAsStrip(Me, EventArgs.Empty)
End Sub
Property Site As System.ComponentModel.ISite Implements System.ComponentModel.IComponent.Site
Get
Return _Site
End Get
Set(ByVal value As System.ComponentModel.ISite)
_Site = value
End Set
End Property
End Class
To enable/disable an Infragistics ButtonTool you can using the following code
myButtonTool.SharedProps.Enabled = True / False
精彩评论