إدارة Cell الضوابط في أوراق العمل

الوصول إلى Cell الضوابط

للوصول إلى عنصر تحكم خلية موجود وتعديله في ورقة العمل ، يمكن للمطورين الوصول إلى عنصر تحكم خلية معين من ملفضوابط جمعورقة عمل من خلال تحديد الخلية (باستخدام اسم الخلية أو موقعها من حيث أرقام الصفوف والأعمدة) التي يتم فيها عرض عنصر التحكم في الخلية. بمجرد الوصول إلى عنصر تحكم الخلية ، يمكن للمطورين تعديل خصائصه في وقت التشغيل. على سبيل المثال ، في المثال الموضح أدناه ، وصلنا إلى ملفخانة الاختيار التحكم في الخلية منورقة عمل وتعديل خاصية التحقق الخاصة به.

الأهمية: ضوابط تحتوي المجموعة على جميع أنواع عناصر التحكم في الخلية في شكلCellControl أشياء. لذلك ، إذا كنت بحاجة إلى الوصول إلى نوع معين من التحكم في الخلية ، على سبيل المثالخانة الاختيار ثم سوف تضطر إلى تلبيس ملفCellControl يعترض علىخانة الاختيار صف دراسي.

// 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();
// Getting the location of the cell that is currently in focus
CellLocation cl = sheet.GetFocusedCellLocation();
// Accessing cell control and typecasting it to CheckBox
Aspose.Cells.GridDesktop.CheckBox cb = (Aspose.Cells.GridDesktop.CheckBox)sheet.Controls[cl.Row, cl.Column];
if (cb != null)
{
// Modifying the Checked property of CheckBox
cb.Checked = true;
}
else
{
MessageBox.Show("Please add control before accessing it.");
}

إزالة Cell الضوابط

لإزالة عنصر تحكم خلية موجود ، يمكن للمطورين ببساطة الوصول إلى ورقة العمل المطلوبة وبعد ذلكيزيل التحكم في الخلية منضوابط جمعورقة عمل من خلال تحديد الخلية (باستخدام اسمها أو رقم الصف والعمود) التي تحتوي على عنصر تحكم الخلية.

// 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();
// Getting the location of the cell that is currently in focus
CellLocation cl = sheet.GetFocusedCellLocation();
// Removing the cell control by specifying the location of cell containing it
sheet.Controls.Remove(cl.Row, cl.Column);