Metin Kutusuna Ada Göre Erişin
Contents
[
Hide
]
Metin Kutusuna Ada Göre Erişin
Daha önce, metin kutularına dizinden erişilirdi.Worksheet.TextBoxeskoleksiyonu, ancak artık bu koleksiyondan metin kutusuna ada göre de erişebilirsiniz. Bu, adını zaten biliyorsanız, metin kutunuza erişmenin kolay ve hızlı bir yoludur.
Aşağıdaki örnek kod önce bir metin kutusu oluşturur ve ona biraz metin ve ad atar. Ardından sonraki satırlarda aynı text box’a ismi ile ulaşıp yazısını yazdırıyoruz.
Metin kutusuna ada göre erişmek için C# kodu
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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ı
İşte yukarıdaki örnek kodun konsol çıktısı.
This is MyTextBox