We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Clearing cell value and formula tag but not formatting

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.

1 Reply

ST stanleyj 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

Loader.
Live Chat Icon For mobile
Up arrow icon