Aspose.Cells.Examples.CSharp.Articles.AccessTextBoxName.Run C# (CSharp) Method

Run() public static method

public static Run ( ) : void
return void
        public static void Run()
        {
            // ExStart:AccessTextBoxName
            // Create an object of the Workbook class
            Workbook workbook = new Workbook();

            // Access first worksheet from the collection
            Worksheet sheet = workbook.Worksheets[0];

            // Add the TextBox to the worksheet
            int idx = sheet.TextBoxes.Add(10, 10, 10, 10);

            // Access newly created TextBox using its index & name it
            TextBox tb1 = sheet.TextBoxes[idx];
            tb1.Name = "MyTextBox";

            // Set text for the TextBox
            tb1.Text = "This is MyTextBox";

            // Access the same TextBox via its name
            TextBox tb2 = sheet.TextBoxes["MyTextBox"];

            // Display the text of the TextBox accessed via name
            Console.WriteLine(tb2.Text);

            Console.WriteLine("Press any key to continue...");
            Console.ReadKey();
            // ExEnd:AccessTextBoxName
        }
    }
AccessTextBoxName