我需要启用/禁用ButtonTool。
在使用Infragistics之前,我使用了一个具有“Enabled”属性的ordinaly WinForms ToolbarButton。
我使用了像这样的数据绑定:
UndoButtonTool.DataBindings.Clear()
UndoButtonTool.DataBindings.Add("Enabled", memory, "CanUndo")
现在如何使用infragistics ButtonTool?
操作
UndoButtonTool.DataBindings.Clear()
UndoButtonTool.DataBindings.Add("SharedProps.Enabled", memory, "CanUndo")
不起作用......
我已经实现了自定义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
答案 0 :(得分:2)
要启用/禁用Infragistics ButtonTool,您可以使用以下代码
myButtonTool.SharedProps.Enabled = True / False