示例#1
0
        /// <summary>
        /// 处理工作簿的 Startup 事件。当此事件激发时,
        /// 将调用 LoadDataSet 方法将 XML 文件中的数据加载到
        /// customerDataSet,将 customerBindingSource 的 DataSource 属性设置
        /// 为 customerDataSet,并将其 DataMember 属性设置为“Customers”。应创建 TechniqueUserControl
        /// 并将其附加到 ActionsPane。
        /// </summary>
        /// <param name="sender">未使用。</param>
        /// <param name="e">未使用。</param>
        private void ThisWorkbook_Startup(object sender, System.EventArgs e)
        {
            // 从 XML 文件加载数据集
            LoadDataSet();

            // 创建 BindingSource
            if (custBindingSource == null)
            {
                custBindingSource = new CustomerBindingSource();
            }
            custBindingSource.DataSource = customerDataSet;
            custBindingSource.DataMember = "Customer";

            // 当 ListObject 尝试更改大小时,在数据网格中添加行将不会取消保护工作表,
            //这将导致发生异常。请将
            // AllowNew 属性设置为 false 可以强制数据集保持相同大小。
            custBindingSource.AllowNew = false;

            // 将用户控件添加到“操作”窗格。
            techUserControl = new TechniqueUserControl();
            ActionsPane.Controls.Add(techUserControl);
        }
示例#2
0
        /// <summary>
        /// Handles the Startup event for the workbook. When the event fires,
        /// LoadDataSet method will be called to load data from XML file into
        /// customerDataSet, set customerBindingSource's DataSource property
        /// to customerDataSet and its DataMember to "Customers". A TechniqueUserControl
        /// Should be created and attached to the ActionsPane.
        /// </summary>
        /// <param name="sender">Unused.</param>
        /// <param name="e">Unused.</param>
        private void ThisWorkbook_Startup(object sender, System.EventArgs e)
        {
            // Loads data set from xml file
            LoadDataSet();

            // Creates BindingSource
            if (custBindingSource == null)
            {
                custBindingSource = new CustomerBindingSource();
            }
            custBindingSource.DataSource = customerDataSet;
            custBindingSource.DataMember = "Customer";

            // Adding rows in the data grid will not unprotect the sheet when the
            // ListObject tries to change size, which will cause an exception. Set the
            // AllowNew property to false to force the data set to stay the same size.
            custBindingSource.AllowNew = false;

            // Adds user control to Actions Pane.
            techUserControl = new TechniqueUserControl();
            ActionsPane.Controls.Add(techUserControl);
        }
示例#3
0
        /// <summary>
        /// 处理工作簿的 Startup 事件。当此事件激发时, 
        /// 将调用 LoadDataSet 方法将 XML 文件中的数据加载到
        /// customerDataSet,将 customerBindingSource 的 DataSource 属性设置  
        /// 为 customerDataSet,并将其 DataMember 属性设置为“Customers”。应创建 TechniqueUserControl
        /// 并将其附加到 ActionsPane。
        /// </summary>
        /// <param name="sender">未使用。</param>
        /// <param name="e">未使用。</param>
        private void ThisWorkbook_Startup(object sender, System.EventArgs e)
        {
            // 从 XML 文件加载数据集
            LoadDataSet();

            // 创建 BindingSource
            if (custBindingSource == null)
                custBindingSource = new CustomerBindingSource();
            custBindingSource.DataSource = customerDataSet;
            custBindingSource.DataMember = "Customer";

            //当 ListObject 尝试更改大小时,在数据网格中添加行将不会取消保护工作表,
            //这将导致发生异常。请将
            // AllowNew 属性设置为 false 可以强制数据集保持相同大小。
            custBindingSource.AllowNew = false;

            // 将用户控件添加到“操作”窗格。
            techUserControl = new TechniqueUserControl();
            ActionsPane.Controls.Add(techUserControl);
        }