Click here to Skip to main content
15,041,025 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I got to have a tabular control that will contain cells hosting different controls across columns. Each column will host same control. For e.g., all cells in column 1 will contain control type Label.

Among those controls, few are extension of predefined controls such as label and textbox while few are user defined controls.

As a first choice I opted DGV as hosting control.
I went through all MSDN documents and took help from google as well to learn things available with DGV. I made custom DGVControl and respectively the columns to host those controls.
This was a lengthy work and messy too at first. It took nearly a month to build DGV with my requirements. Somehow I achieved 80% of required functionality and rest 20% seems to be difficult for me since there are hundreds of lines of code for making hosted control cooperate with the business model and also satisfying basic DGV control's properties.
Then I decided to not to use DGV since it might not be scalable in future.

As a 2nd choice, I decided to use a TLP(TableLayoutPanel).
I extended basic TLP in my class and added methods required.
Hosting controls in TLP is much easier than that of DGV. It took just 3 days to build it as required.
Somehow, TLP takes considerable time to Paint itself. Since, there is no built in function to remove a specific row in TLP, I deleted controls from required row manually and shifted all rows below it to one row up. With just 20 entries, TLP takes nearly 1.5 seconds to repaint itself.
For code, there are no loops that are working for too long, neither there are any heavy background thread that can cause this.
I guess TLP is not made for the functionality I need. Its just a panel to layout controls on form for proper UX.

I am stucked what to use for this very purpose. Please guide.

What I have tried:

Spent lots of time making DGV and TLP work as required but no help.
Posted
Updated 4-Dec-16 1:05am
v2

1 solution

I did something similar with a Table Layout Panel, but instead of removing the controls, I just made them invisible. The rows were set to adjust their height to contents, but as there were no visible contents in the row, the height adjusted itself to zero. A lot less redrawing of controls required this way. It means you need to keep an index of TLP row numbers to logical row numbers, but that is not too difficult to maintain.

Not too sure if this methodology would be suitable in your case, but the concept may help.
   
Comments
Member 11040029 4-Dec-16 7:25am
   
thanks @Midi_Mick! I tried this way too. Its great. But do you think there will be any performance issues if TLP contains nearly about 200 rows? By performance I mean anything, such as load on threads, or rendering issues or something other?
Member 11040029 4-Dec-16 7:25am
   
Also, can you please rate this question so that this question can get attention.
Midi_Mick 4-Dec-16 7:44am
   
Performance of the redraw will depend a lot on how many of the rows are actually visible in the viewport. However, by just setting the one row basically to invisible, it does not have to recalculate the layouts for any control that is not visible. You should find considerable improvement over your previous method of changing the control locations.
One other thing you should do, and it helps a lot, is to set call SuspendLayout for the TLP before setting the visibility of the contained controls, and call ResumeLayout after all modifications have been done - this will ensure only one redraw per set of modifications.
Member 11040029 4-Dec-16 7:54am
   
I tried this way. Suspension helps. But this is not enough. Rendering is still considerably slow after adding just 10 rows :(
I am stucked hard on this issue!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900