ListObject.DataBindingFailure 事件
當某個條件導致 ListObject 控制項的資料繫結失敗時便會發生。
命名空間: Microsoft.Office.Tools.Excel
組件: Microsoft.Office.Tools.Excel (在 Microsoft.Office.Tools.Excel.dll 中)
語法
'宣告
Event DataBindingFailure As EventHandler
event EventHandler DataBindingFailure
備註
導致失敗之條件的範例,是使用者將 ListObject 控制項置放至另一個已經在置放位置中的 ListObject 控制項。 新控制項的資料繫結會失敗,而此控制項會引發這個事件。
範例
下列程式碼範例會建立 ListObject,並新增 DataBindingFailure 事件的事件處理常式。 如果 list1 要繫結至資料來源,但是在繫結中斷時,會攔截事件並出現訊息顯示繫結狀態。
這是示範文件層級自訂的版本。
WithEvents List4 As Microsoft.Office.Tools.Excel.ListObject
Private Sub ListObject_DataBindingFailure()
List4 = Me.Controls.AddListObject( _
Me.Range("A1", "C4"), "List4")
End Sub
Private Sub List4_DataBindingFailure(ByVal sender As Object, _
ByVal e As EventArgs) Handles List4.DataBindingFailure
MessageBox.Show("Data binding is " & _
List4.IsBinding)
End Sub
Microsoft.Office.Tools.Excel.ListObject list4;
private void ListObject_DataBindingFailure()
{
list4 = this.Controls.AddListObject(
this.Range["A1", "C4"], "list4");
list4.DataBindingFailure += new EventHandler(list4_DataBindingFailure);
}
void list4_DataBindingFailure(object sender, EventArgs e)
{
MessageBox.Show("Data binding is " + list4.IsBinding);
}
這是示範應用程式層級增益集的版本。
WithEvents List4 As ListObject
Private Sub ListObject_DataBindingFailure()
Dim NativeWorksheet As Microsoft.Office.Interop.Excel.Worksheet =
Me.Application.Worksheets(1)
Dim vstoWorksheet As Microsoft.Office.Tools.Excel.Worksheet =
Globals.Factory.GetVstoObject(NativeWorksheet)
List4 = vstoWorksheet.Controls.AddListObject( _
vstoWorksheet.Range("A1", "C4"), "List4")
End Sub
Private Sub List4_DataBindingFailure(ByVal sender As Object, _
ByVal e As EventArgs) Handles List4.DataBindingFailure
System.Windows.Forms.MessageBox.Show("Data binding is " & _
List4.IsBinding)
End Sub
ListObject list4;
private void ListObject_DataBindingFailure()
{
Worksheet vstoWorksheet =
Globals.Factory.GetVstoObject(this.Application.ActiveWorkbook.Worksheets[1]);
list4 = vstoWorksheet.Controls.AddListObject(
vstoWorksheet.Range["A1", "C4"], "list4");
list4.DataBindingFailure += new EventHandler(list4_DataBindingFailure);
}
void list4_DataBindingFailure(object sender, EventArgs e)
{
System.Windows.Forms.MessageBox.Show("Data binding is " + list4.IsBinding);
}
.NET Framework 安全性
- 完全信任立即呼叫者。這個成員無法供部分信任的程式碼使用。如需詳細資訊,請參閱從部分受信任程式碼使用程式庫。