|
Il presente articolo è stato tradotto automaticamente. Passare il puntatore sulle frasi nell'articolo per visualizzare il testo originale. Ulteriori informazioni.
|
Traduzione
Originale
|
Evento ListObject.BeforeAddDataBoundRow
Spazio dei nomi: Microsoft.Office.Tools.Excel
Assembly: Microsoft.Office.Tools.Excel (in Microsoft.Office.Tools.Excel.dll)
private void ListObject_BeforeAddDataBoundRow() { // Create a new DataSet and DataTable. DataSet ds = new DataSet(); DataTable dt = ds.Tables.Add("Customers"); dt.Columns.Add(new DataColumn("LastName")); dt.Columns.Add(new DataColumn("FirstName")); // Add a new row to the DataTable. DataRow dr = dt.NewRow(); dr["LastName"] = "Chan"; dr["FirstName"] = "Gareth"; dt.Rows.Add(dr); // 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.BeforeAddDataBoundRow += new Microsoft.Office.Tools.Excel. BeforeAddDataBoundRowEventHandler( list1_BeforeAddDataBoundRow); } void list1_BeforeAddDataBoundRow(object sender, Microsoft.Office.Tools.Excel.BeforeAddDataBoundRowEventArgs e) { e.Cancel = true; MessageBox.Show("This data is read-only."); }
private void ListObject_BeforeAddDataBoundRow() { // Create a new DataSet and DataTable. DataSet ds = new DataSet(); DataTable dt = ds.Tables.Add("Customers"); dt.Columns.Add(new DataColumn("LastName")); dt.Columns.Add(new DataColumn("FirstName")); // Add a new row to the DataTable. DataRow dr = dt.NewRow(); dr["LastName"] = "Chan"; dr["FirstName"] = "Gareth"; dt.Rows.Add(dr); // Create a list object. Worksheet vstoWorksheet = Globals.Factory.GetVstoObject(this.Application.ActiveWorkbook.Worksheets[1]); ListObject list1 = vstoWorksheet.Controls.AddListObject( vstoWorksheet.Range["A1"], "list1"); // Bind the list object to the DataTable. list1.AutoSetDataBoundColumnHeaders = true; list1.SetDataBinding(ds, "Customers", "LastName", "FirstName"); // Create the event handler. list1.BeforeAddDataBoundRow += new BeforeAddDataBoundRowEventHandler( list1_BeforeAddDataBoundRow); } void list1_BeforeAddDataBoundRow(object sender, Microsoft.Office.Tools.Excel.BeforeAddDataBoundRowEventArgs e) { e.Cancel = true; System.Windows.Forms.MessageBox.Show("This data is read-only."); }
- Attendibilità totale per il chiamante immediato. Impossibile utilizzare questo membro in codice parzialmente attendibile. Per ulteriori informazioni, vedere Utilizzo di librerie da codice parzialmente attendibile.