Sorry i havent made that obvious enough, its not ASP, its WinForms.
Main Topics
Browse All TopicsHi
I have made a UserControl which draws itself using
1 Panel, within that panel it will load
1 - n (standard around 3) UserControls
This UserControl has 1 TableLayout with 7 Columns.
Each column will have 1 Button and 1-10 additional USercontrol which holds 2 labels.
I dont think this layout is THAT complicated however it will render quite slowly, you can see each of the last usercontrols being added one at a time.
I tried doing a SuspendLayout to prevent the screen from being updated, however this changed nothing at all.
Cant i use suspendlayout to do this or ?
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Hmm i just tried implementing it,
Did help concerning the "flickering", however it just resulted in the system seeming to take alot of time to load.
So no speed enhancements, seems that the construction is simply to slow.
Loading this http://www.scoding.dk/view
The data is not the issue its iterated very fast, however it seems that the problem is the way that the panels resize and realign to each new panel.
I can litteraly see every single panel being added one at a time, resulting in the other panels resizing.
Hmm i found part of a solution.
within the Constructor of the ShiftSchedule, i added all the children controls.
Afterwards adding the ShiftSchedule to the form resulting in all children controls being drawn without any suspend layout, meaning after each drawn controls the layout of all children is adjusted.
If i do it like this it boosts performance greatly
ShiftSchedule a = new ShiftSchedule();
panel.Controls.Add(a);
a.LoadSubcontrols();
I have made a new post to try to figure that part out:
http://www.experts-exchang
Its a UserControl.
This is copied from the other post mentioned:
Hi
Iam adding alot of controls to a UserControl, and when all the children are rendered i need the layout of specific panels to be suspended.
However the OnPaint doesnt seem to be the one taking care of this part.
I also tried OnLayout with no results either.
I have some code like this:
ShiftSchedule mSched;
mSched = new ShiftSchedule(item, shiftList,mDate) { Dock = DockStyle.Top };
shiftSchedulePanel.Control
mSched.LoadGrid();
Implented like this:
This way is very slow:
public ShiftSchedule(ShiftGroup mGroup, ShiftList sList, DateTime mDate)
{
InitializeComponent();
this.mDate = mDate;
this.SelectedGroup = mGroup;
shiftList = sList;
lbGroupName.Text = mGroup.Name;
ctlShiftDay1.LoadValues(mD
ctlShiftDay2.LoadValues(mD
ctlShiftDay3.LoadValues(mD
ctlShiftDay4.LoadValues(mD
ctlShiftDay5.LoadValues(mD
ctlShiftDay6.LoadValues(mD
ctlShiftDay7.LoadValues(mD
}
public void LoadGrid()
{
}
However doing this is okay fast:
public ShiftSchedule(ShiftGroup mGroup, ShiftList sList, DateTime mDate)
{
InitializeComponent();
this.mDate = mDate;
this.SelectedGroup = mGroup;
shiftList = sList;
lbGroupName.Text = mGroup.Name;
}
public void LoadGrid()
{
ctlShiftDay1.LoadValues(mD
ctlShiftDay2.LoadValues(mD
ctlShiftDay3.LoadValues(mD
ctlShiftDay4.LoadValues(mD
ctlShiftDay5.LoadValues(mD
ctlShiftDay6.LoadValues(mD
ctlShiftDay7.LoadValues(mD
}
It seems that there is a large difference on the two approaches and i would like to know why ?!
I though that it could have something to do with how OnPaint is done but it doesnt seem to.
protected override void OnPaint(PaintEventArgs e)
{
panel1.SuspendLayout();
tableLayoutPanel1.SuspendL
base.OnPaint(e);
panel1.ResumeLayout();
tableLayoutPanel1.ResumeLa
}
Does anyone have any ideas why this is happening, and what the best way of doing this would be ?
Well i can try to give you some more information:
This is the code thats inside the LoadValues, the thing i find very wierd is that doing th e LoadValues within the contructor of the ShiftSchedule and then adding the ShiftSchedule to my form is very slow.
However Adding the ShiftSchedule first and then loading the values is like 10-20 times faster.
Does that give you a better idea or would you need even more information ?
public void LoadValues(DateTime mDate, int groupID, ShiftList shiftList)
{
this.groupID = groupID;
this.selectedDate = mDate;
this.shiftList = shiftList;
shiftList.ShiftAdded += new ShiftList.AddShiftEventHan
shiftList.ShiftChanged += new ShiftList.EditShiftEventHa
reloadPanel();
}
void reloadPanel()
{
this.SetStyle(ControlStyle
this.SetStyle(ControlStyle
this.SetStyle(ControlStyle
shiftPanel.SuspendLayout()
shiftPanel.Controls.Clear(
var q = (from a in shiftList.GetList()
where
a.Date.Date == selectedDate.Date
&& a.GroupID == groupID
orderby a.ShiftTime descending
select a);
foreach (Shift item in q)
{
addToPanel(item);
}
shiftPanel.ResumeLayout();
}
Red ANTS
http://www.red-gate.com/Pr
CodeProject: The Simple Profiler for .NET Developers.
http://www.codeproject.com
.NET CODE TUNING
Make Your Apps Fly with the New Enterprise Performance Tool
http://msdn.microsoft.com/
Business Accounts
Answer for Membership
by: RedKelvinPosted on 2009-03-09 at 18:23:17ID: 23842843
Hi,
-exchange. com/Web_De velopment/ Web_Langua ges-Standa rds/HTML/Q _22889170. html
You could try this approach
http://www.experts