The Syncfusion native Blazor components library offers 70+ UI and Data Viz web controls that are responsive and lightweight for building modern web apps.
.NET PDF framework is a high-performance and comprehensive library used to create, read, merge, split, secure, edit, view, and review PDF files in C#/VB.NET.
Hi,
I''ve noticed that when I do a gridmodel.Clear(clearStyle = false), all the cellvalues are reset but any formula tags remain.
I know if I set clearStyle = True, then everything would be cleared, but in my case I need to preserve all formatting.
How can I clear the value and formula tag of a range of cells?
Thanks.
STstanleyj Syncfusion Team February 17, 2006 04:50 PM UTC
Hi Alex,
To remove the value in the Tag, the selected range has to be looped through. Here is the code to Clear the cell value and the tag.
public void Clear()
{
GridRangeInfo selectedRange = this.gridControl1.Selections.Ranges.ActiveRange;
// Clear Only the value && tag
for (int rowIndex = selectedRange.Top; rowIndex <= selectedRange.Bottom; rowIndex++)
{
for (int colIndex = selectedRange.Left; colIndex <= selectedRange.Right; colIndex++)
{
GridStyleInfo style = this.gridControl1.Model[rowIndex, colIndex];
this.gridControl1.Model[rowIndex, colIndex].Tag = null;
if (style.GetFormattedText(style.CellValue).Length > 0)
style.ApplyFormattedText("");
}
}
}
Best regards,
Stanley