管理列中的 Cell 控件
Contents
[
Hide
]
本主题讨论有关使用 Aspose.Cells.GridDesktop API 管理列中的单元格控件的一些重要概念。我们将解释开发人员如何从其工作表的列中访问、修改和删除单元格控件。让我们来看看它。
访问 Cell 控件
要访问和修改列中现有的单元格控件,开发人员可以使用Aspose.Cells.GridDesktop.Data.GridColumn.访问单元格控件后,开发人员可以在运行时修改其属性。例如,在下面给出的示例中,我们访问了一个现有的复选框来自特定的细胞控制Aspose.Cells.GridDesktop.Data.GridColumn并修改了它的 Checked 属性。
重要的: CellControl 属性以以下形式提供单元格控件细胞控制目的。所以,如果你需要访问特定类型的单元格控件,比如说复选框那么你将不得不强制转换细胞控制反对复选框班级。
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 | |
// 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."); | |
} |
删除 Cell 控件
要删除现有的单元格控件,开发人员可以简单地访问所需的工作表,然后去掉通过使用特定列的单元格控件删除单元格控件的方法Aspose.Cells.GridDesktop.Data.GridColumn.
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 | |
// Accessing the worksheet of the Grid that is currently active | |
Worksheet sheet = gridDesktop1.GetActiveWorksheet(); | |
// Removing cell control from the column | |
sheet.Columns[2].RemoveCellControl(); |
中的每一列列的集合工作表由一个实例表示Aspose.Cells.GridDesktop.Data.GridColumn班级。