2
我需要啓用/禁用ButtonTool。禁用Infragistics工具欄按鈕(ButtonTool)
在使用Infragistics之前,我使用了一個ordinaly WinForms ToolbarButton,它有一個屬性「Enabled」。
我用這樣的數據綁定:我怎會現在使用的Infragistics ButtonTool
UndoButtonTool.DataBindings.Clear()
UndoButtonTool.DataBindings.Add("Enabled", memory, "CanUndo")
?
做
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
T UndoButtonTool.DataBindings.Add(「啓用」,memory.SharedProps,「CanUndo」),它應該工作。我積極使用Infragistics併成功綁定了Enabled屬性。 – 2011-01-22 21:35:29