قم بالوصول إلى مربع النص بالاسم
Contents
[
Hide
]
قم بالوصول إلى مربع النص بالاسم
في وقت سابق ، يتم الوصول إلى مربعات النص عن طريق الفهرس من ملفورقة العملالمجموعة ولكن الآن يمكنك أيضًا الوصول إلى مربع النص بالاسم من هذه المجموعة. هذه طريقة ملائمة وسريعة للوصول إلى مربع النص الخاص بك إذا كنت تعرف اسمه بالفعل.
يقوم نموذج التعليمات البرمجية التالي أولاً بإنشاء مربع نص وتعيين بعض النص والاسم له. ثم في الأسطر التالية ، نصل إلى نفس مربع النص باسمه ونطبع نصه.
C# كود للوصول إلى مربع النص بالاسم
This file contains 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(); |
ناتج وحدة التحكم التي تم إنشاؤها بواسطة نموذج التعليمات البرمجية
هنا هو إخراج وحدة التحكم من نموذج التعليمات البرمجية أعلاه.
This is MyTextBox