إدارة عناصر التحكم في الأعمدة
الوصول إلى تحكم الخلية
يمكن للمطورين الوصول إلى وتعديل ضوابط الخلية الحالية في العمود ببساطة باستخدام خاصية CellControl لـ Aspose.Cells.GridDesktop.Data.GridColumn. وبمجرد الوصول إلى ضابط الخلية، يمكن للمطورين تعديل خصائصها أثناء التشغيل. على سبيل المثال، في المثال المعطى أدناه، لقد وصلنا إلى ضابط خلية CheckBox موجود من عمود معين لـ Aspose.Cells.GridDesktop.Data.GridColumn وقمنا بتعديل خاصيتها Checked.
مهم: خاصية CellControl توفر ضابط خلية في شكل كائن CellControl. لذا، إذا كنت بحاجة إلى الوصول إلى نوع محدد من ضابط الخلية، مثل CheckBox على سبيل المثال، فيجب على الشخص نوع المضيف لكائن CellControl إلى فئة CheckBox.
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// Accessing the worksheet of the Grid that is currently active | |
Worksheet sheet = gridDesktop1.GetActiveWorksheet(); | |
// Accessing cell control in the column and typecasting it to CheckBox | |
Aspose.Cells.GridDesktop.CheckBox cb = (Aspose.Cells.GridDesktop.CheckBox)sheet.Columns[2].CellControl; | |
if (cb != null) | |
{ | |
// Modifying the Checked property of CheckBox | |
cb.Checked = true; | |
} | |
else | |
{ | |
MessageBox.Show("Please add control before accessing it."); | |
} |
إزالة تحكم الخلية
لإزالة ضابط خلية موجود، يمكن للمطورين ببساطة الوصول إلى ورقة العمل المطلوبة ثم إزالة ضابط الخلية من العمود المحدد باستخدام الطريقة RemoveCellControl في Aspose.Cells.GridDesktop.Data.GridColumn.
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// Accessing the worksheet of the Grid that is currently active | |
Worksheet sheet = gridDesktop1.GetActiveWorksheet(); | |
// Removing cell control from the column | |
sheet.Columns[2].RemoveCellControl(); |