| This topic discusses some important concepts about managing cell controls in columns using Aspose.Cells.GridDesktop API. We will explain that how can developer access, modify and remove cell controls from the columns of their worksheets. Let's have a look into it. |
Managing Cell Controls in Columns
Accessing Cell Controls
To access and modify an existing cell control in the column, developers can use the CellControl property of a GridColumn. Once a cell control is accessed, developers can modify its properties at runtime. For an instance, in the example given below, we have accessed an existing CheckBox cell control from a specific GridColumn and modified its Checked property.
IMPORTANT: CellControl property provides a cell control in the form of CellControl object. So, if you need to access a specific type of cell control, say CheckBox then you will have to typecast the CellControl object to CheckBox class.
Example:
//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; //Modifying the Checked property of CheckBox cb.Checked = true;
'Accessing the worksheet of the Grid that is currently active Dim sheet As Worksheet = gridDesktop1.GetActiveWorksheet() 'Accessing cell control in the column and typecasting it to CheckBox Dim cb As Aspose.Cells.GridDesktop.CheckBox = CType(sheet.Columns(2).CellControl, Aspose.Cells.GridDesktop.CheckBox) 'Modifying the Checked property of CheckBox cb.Checked = True
Removing Cell Controls
To remove an existing cell control, developers can simply access a desired worksheet and then Remove the cell control from the specific column by using the RemoveCellControl method of GridColumn.
Example:
//Accessing the worksheet of the Grid that is currently active Worksheet sheet = gridDesktop1.GetActiveWorksheet(); //Removing cell control from the column sheet.Columns[2].RemoveCellControl();
'Accessing the worksheet of the Grid that is currently active Dim sheet As Worksheet = gridDesktop1.GetActiveWorksheet() 'Removing cell control from the column sheet.Columns(2).RemoveCellControl()
| Each column in the Columns collection of the Worksheet is represented by an instance of GridColumn class. |

