B2026-003 Imported memory handling in the FlexGrid (table) code for when we are replacing many RO values in table cells

This commit is contained in:
2026-01-23 15:55:36 -05:00
parent a4ea200e38
commit 258b1d2d1f
2 changed files with 28 additions and 22 deletions

View File

@@ -272,21 +272,24 @@ namespace Volian.Controls.Library
for (int i = 0; i < rows * cols; i++)
datum.Add("|");
XmlNodeList nl = xd.SelectNodes("C1FlexGrid/Cells/Cell/Data");
string data = string.Empty;
// B2026-003 use StringBuilder a "using" statement around the RichTextBox for better mememory management
StringBuilder data = new StringBuilder();
foreach (XmlNode xn in nl)
{
RichTextBox rtb = new RichTextBox();
rtb.Rtf = xn.InnerText;
XmlAttribute xa = xn.ParentNode.Attributes.GetNamedItem("index") as XmlAttribute;
string[] rc = xa.InnerText.Split(',');
int r = int.Parse(rc[0]);
int c = int.Parse(rc[1]);
int index = r * cols + c;
datum[index] = "|" + (rtb.Text == "" ? "" : rtb.Text);
using (RichTextBox rtb = new RichTextBox())
{
rtb.Rtf = xn.InnerText;
XmlAttribute xa = xn.ParentNode.Attributes.GetNamedItem("index") as XmlAttribute;
string[] rc = xa.InnerText.Split(',');
int r = int.Parse(rc[0]);
int c = int.Parse(rc[1]);
int index = r * cols + c;
datum[index] = "|" + (rtb.Text == "" ? "" : rtb.Text);
}
}
foreach (string s in datum)
data += s;
return data;
data.Append(s);
return data.ToString();
}
private string GetCellFormatString(XmlDocument xd)
{