Hantera Cell kontroller i kolumner
Åtkomst till Cell kontroller
För att komma åt och ändra en befintlig cellkontroll i kolumnen kan utvecklare använda egenskapen CellControl för aAspose.Cells.GridDesktop.Data.GridColumn . När en cellkontroll väl har nåtts kan utvecklare ändra dess egenskaper under körning. Till exempel, i exemplet nedan, har vi kommit åt en befintligKryssruta cellkontroll från en specifikAspose.Cells.GridDesktop.Data.GridColumn och ändrade dess kontrollerade egenskap.
VIKTIG: CellControl-egenskapen tillhandahåller en cellkontroll i form avCellControlobjekt. Så, om du behöver komma åt en specifik typ av cellkontroll, sägKryssruta då måste du typcastaCellControl protestera motKryssruta klass.
// 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."); | |
} |
Ta bort Cell kontroller
För att ta bort en befintlig cellkontroll kan utvecklare helt enkelt komma åt ett önskat kalkylblad och sedanTa bort cellkontrollen från den specifika kolumnen genom att användaTa bortCellControl metod avAspose.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(); |