I'm populating the RadDataGridView via setting up the columns, then suppling an array of objects for each row I need to add. I can't use a bound grid as we need columns that are not actual values of the object (for example View/Edit buttons that then open the record for the user). I cannot run this in a virtual grid as we are using the grouping functionality to allow users to organize the data. Currently populating the grid takes over half the time of the process. Anyone have additional suggestion for things to try?
public void AdvancedRowsPopulation(IList<object[]> rows, bool doReset = true)
{
var tmr = System.Diagnostics.Stopwatch.StartNew();
radGridView1.BeginUpdate();
//Have to reset the columns so the object[] matches up again
string settings = GetGridXml();
SetGridToXML(BaseGridSettingsXML);
DetachColumnListeners();
tmr.Stop();
Log.Info($"Grid to default took {tmr.ElapsedMilliseconds / 1000.0}s.");
tmr = System.Diagnostics.Stopwatch.StartNew();
if (doReset)
{
radGridView1.Rows.Clear();
cachedRows = new List<object[]>();
lastDataSet = new DataTable();
foreach (var col in radGridView1.Columns) lastDataSet.Columns.Add(col.HeaderText);
}
for (int y=0;y<rows.Count;y++)
{
var row =rows[y];
radGridView1.Rows.Add(row);
lastDataSet.Rows.Add(row);
}
lblDataCount.Text = radGridView1.Rows.Count.ToString();
tmr.Stop();
Log.Info($"Grid Row Population took {tmr.ElapsedMilliseconds / 1000.0}s.");
tmr = System.Diagnostics.Stopwatch.StartNew();
BaseGridSettingsXML = GetGridXml();
//Set grid back to what the user had last seen
SetGridToXML(settings);
radGridView1.EndUpdate();
tmr.Stop();
Log.Info($"Grid to user's layout took {tmr.ElapsedMilliseconds / 1000.0}s.");
}