Ada Göre Metin Kutusuna Eriş

Ada Göre Metin Kutusuna Eriş

Önceden, metin kutularına Worksheet.TextBoxes koleksiyonundan dizine göre erişiliyordu, ancak şimdi aynı koleksiyondan ada göre metin kutusuna da erişebilirsiniz. Bu, metin kutusuna zaten adını biliyorsanız uygun ve hızlı bir erişim sağlar.

Aşağıdaki örnek kod öncelikle bir metin kutusu oluşturur ve ona bazı metin ve ad atar. Ardından aynı metin kutusuna adıyla erişir ve metnini yazdırır.

Ada ile metin kutusuna erişen C# kodu

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// 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();

Örnek kod tarafından oluşturulan konsol çıktısı

Yukarıdaki örnek kodun konsol çıktısı burada gösterilmektedir.

This is MyTextBox