تحديث عنصر تحكم ActiveX ComboBox
Contents
[
Hide
]
سيناريوهات الاستخدام الممكنة
يمكنك قراءة أو كتابة قيم عنصر تحكم ActiveX ComboBox باستخدام Aspose.Cells. يرجى الوصول إلى عنصر تحكم ActiveX عبرالشكل وتحقق من نوعها عبرالنوع الملكية ، يجب أن تعودنوع التحكم القيمة ثم نوعها فيComboBoxActiveXControlالكائن وقراءة أو تعديل خصائصه المختلفة.
يرجى تنزيل ملفنموذج ملف اكسل المستخدمة في نموذج التعليمات البرمجية التالي.
تحديث عنصر تحكم ActiveX ComboBox
توضح لقطة الشاشة التالية تأثير نموذج التعليمات البرمجية على ملفنموذج ملف اكسلكما ترى ، تم تحديث قيمة ActiveX ComboBox إلى “هذا هو عنصر تحكم مربع التحرير والسرد”.
![]() |
---|
عينة من الرموز
يقوم نموذج التعليمات البرمجية التالي بتحديث قيمة عنصر تحكم ActiveX ComboBox الموجود داخل ملفنموذج ملف اكسل.
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 | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
// Create a workbook | |
Workbook wb = new Workbook(dataDir + "SourceFile.xlsx"); | |
// Access first shape from first worksheet | |
Shape shape = wb.Worksheets[0].Shapes[0]; | |
// Access ActiveX ComboBox Control and update its value | |
if (shape.ActiveXControl != null) | |
{ | |
// Access Shape ActiveX Control | |
ActiveXControl c = shape.ActiveXControl; | |
// Check if ActiveX Control is ComboBox Control | |
if (c.Type == ControlType.ComboBox) | |
{ | |
// Type cast ActiveXControl into ComboBoxActiveXControl and change its value | |
ComboBoxActiveXControl comboBoxActiveX = (ComboBoxActiveXControl)c; | |
comboBoxActiveX.Value = "This is combo box control with updated value."; | |
} | |
} | |
// Save the workbook | |
wb.Save(dataDir + "OutputFile_out.xlsx"); |