I am currently creating a permission form in Windows C# and the purpose of this screen is to have a matrix of checkboxes, column being each userGroup and row being each report.
I have designed the screen, creating dynamically as many checkboxes as userGroups x reports. However the time it takes to load the screen is very slow. (Around 400 checkboxes currently)
Here is my code:
Label lblU;
Label lblR;
Label line;
for (int u = 0; u < userGroups.Count; u++)
{
lblU = new Label();
...
lblU.Location = new Point(60 + (u * 100) , 10);
this.Controls.Add(lblU);
}
for (int r = 0; r < allReports.Count; r++)
{
lblR = new Label();
...
lblR.Location = new Point(10, 60 + (r * 80));
this.Controls.Add(lblR);
}
for (int r = 0; r < allReports.Count; r++)
{
line = new Label();
...
line.Location = new Point(10, 40 + (r * 80));
this.Controls.Add(line);
}
CheckBox box;
for (int u = 0; u < userGroups.Count; u++)
{
for (int r = 0; r < allReports.Count; r++)
{
box = new CheckBox();
...
box.Location = new Point((u * 100) + 60, 60 + ((r * 80) + 25));
this.Controls.Add(box);
}
}
I tried other controls, such as CheckedListBox, but they couldn't achieve what I want e.g. there are no functionality in CheckedListBox to separate checkboxes as I want per column.
What is the most efficient way to cut down on loading time?
PS: I am also having Infragistics controls 14.2
Aucun commentaire:
Enregistrer un commentaire