コード例 #1
0
        //</Snippet11>


        //---------------------------------------------------------------------
        void Test2()
        {
            //<Snippet5>
            Microsoft.Office.Tools.Excel.Controls.Button control1 =
                this.Controls.AddButton(this.Range["A1"], "control1");
            //</Snippet5>


            //<Snippet6>
            control1.Placement = Microsoft.Office.Interop.Excel.XlPlacement.xlFreeFloating;
            //</Snippet6>
        }
コード例 #2
0
        private void SetBindingContext()
        {
            namedRange1 = this.Controls.AddNamedRange(
                this.Range["A1"], "namedRange1");

            // Create a button that scrolls through the data
            // displayed in the NamedRange.
            button1 = this.Controls.AddButton(50, 20, 100, 20,
                                              "button1");
            button1.Text   = "Display next item";
            button1.Click += new EventHandler(button1_Click);

            // Create a data table with one column.
            ds = new DataSet();
            DataTable  table   = ds.Tables.Add("Customers");
            DataColumn column1 = new DataColumn("Names", typeof(string));

            table.Columns.Add(column1);

            // Add the names to the table.
            DataRow row;

            for (int i = 0; i < customerNames.Length; i++)
            {
                row          = table.NewRow();
                row["Names"] = customerNames[i];
                table.Rows.Add(row);
            }

            // Create a new Binding that links the Value2 property
            // of the NamedRange and the Names column.
            //<Snippet4>
            Binding binding1 = new Binding("Value2", ds, "Customers.Names", true);

            namedRange1.DataBindings.Add(binding1);
            //</Snippet4>
        }