Interfaccia OriginalDataRestoredEventArgs
fornisce i dati per OriginalDataRestored evento.
Spazio dei nomi: Microsoft.Office.Tools.Excel
Assembly: Microsoft.Office.Tools.Excel (in Microsoft.Office.Tools.Excel.dll)
Sintassi
'Dichiarazione
<GuidAttribute("bf384426-1805-4e64-9d3e-79ec84d8bbbd")> _
Public Interface OriginalDataRestoredEventArgs
[GuidAttribute("bf384426-1805-4e64-9d3e-79ec84d8bbbd")]
public interface OriginalDataRestoredEventArgs
Il tipo OriginalDataRestoredEventArgs espone i seguenti membri.
Proprietà
Nome | Descrizione | |
---|---|---|
ChangeReason | Ottiene un valore che indica il motivo per cui i dati originali sono stati ripristinati. | |
ChangeType | Ottiene un valore che indica il tipo di ripristino eseguito da un oggetto ListObject controllare. |
In alto
Note
OriginalDataRestored l'evento viene generato da un oggetto ListObject controllare quando si ripristina i dati allo stato originale. ChangeType l'argomento fornisce informazioni sul tipo di ripristino ListObject controllare eseguito e ChangeReason vengono fornite informazioni sul motivo per cui il ripristino è stato eseguito.
Esempi
Nell'esempio di codice riportato di seguito viene creato un oggetto DataTable e ListObjecte associazioni ListObject in DataTable. Crea quindi OriginalDataRestored gestore eventi. Per verificare l'evento, fare clic con il pulsante destro del mouse su una lettera della colonna su ListObject nel foglio 1 e quindi fare clic su Eliminazione nel menu di scelta rapida. Il gestore eventi sostituisce i dati dell'intestazione di colonna e di colonna e per ottenere un'indicazione di messaggi che tipo di dati è stato ripristinato e il motivo per cui i dati originali sono stati ripristinati.
Questo esempio è valido per una personalizzazione a livello di documento.
WithEvents OriginalDataRestoredList As _
Microsoft.Office.Tools.Excel.ListObject
Private Sub ListObject_OriginalDataRestored()
' Create a new DataSet and DataTable.
Dim ds As New DataSet()
Dim dt As DataTable = ds.Tables.Add("Customers")
Dim lastName As New DataColumn("LastName")
dt.Columns.Add(lastName)
dt.Columns.Add(New DataColumn("FirstName"))
' Add two new rows to the DataTable.
Dim dr1 As DataRow = dt.NewRow()
dr1("LastName") = "Chan"
dr1("FirstName") = "Gareth"
dt.Rows.Add(dr1)
Dim dr2 As DataRow = dt.NewRow()
dr2("LastName") = "Nitsche"
dr2("FirstName") = "Sonja"
dt.Rows.Add(dr2)
' Create a list object.
OriginalDataRestoredList = Me.Controls.AddListObject( _
Me.Range("A1"), "OriginalDataRestoredList")
' Bind the list object to the DataTable.
OriginalDataRestoredList.AutoSetDataBoundColumnHeaders = True
OriginalDataRestoredList.SetDataBinding(ds, "Customers", _
"LastName", "FirstName")
End Sub
Private Sub List1_OriginalDataRestored(ByVal sender As Object, _
ByVal e As Microsoft.Office.Tools.Excel.OriginalDataRestoredEventArgs) _
Handles OriginalDataRestoredList.OriginalDataRestored
MessageBox.Show("This data is bound to a data source and " & _
"will be restored. This change is: " & e.ChangeType.ToString() & _
". The reason is: " & e.ChangeReason.ToString() + ".")
End Sub
private void ListObject_OriginalDataRestored()
{
// Create a new DataSet and DataTable.
DataSet ds = new DataSet();
DataTable dt = ds.Tables.Add("Customers");
DataColumn lastName = new DataColumn("LastName");
dt.Columns.Add(lastName);
dt.Columns.Add(new DataColumn("FirstName"));
// Add two new rows to the DataTable.
DataRow dr1 = dt.NewRow();
dr1["LastName"] = "Chan";
dr1["FirstName"] = "Gareth";
dt.Rows.Add(dr1);
DataRow dr2 = dt.NewRow();
dr2["LastName"] = "Nitsche";
dr2["FirstName"] = "Sonja";
dt.Rows.Add(dr2);
// Create a list object.
Microsoft.Office.Tools.Excel.ListObject list1 =
this.Controls.AddListObject(
this.Range["A1"], "list1");
// Bind the list object to the DataTable.
list1.AutoSetDataBoundColumnHeaders = true;
list1.SetDataBinding(ds, "Customers", "LastName",
"FirstName");
// Create the event handler.
list1.OriginalDataRestored += new
Microsoft.Office.Tools.Excel.
OriginalDataRestoredEventHandler(list1_OriginalDataRestored);
}
void list1_OriginalDataRestored(object sender,
Microsoft.Office.Tools.Excel.OriginalDataRestoredEventArgs e)
{
MessageBox.Show("This data is bound to a data source and " +
"will be restored. This change is: " + e.ChangeType.ToString() +
". The reason is: " + e.ChangeReason.ToString() + ".");
}