Question

I have a WinForms application that allows you to edit documents. Each document is made of chapters and each chapter holds a collection of RTF blocks. The RTF blocks are loaded in a PanelControl using Dock = DockStyle.Top.

The problem is that when the total height of a chapter gets too large (estimating > 32768 pixels) the lower blocks are not properly docked: they appear behind one another. When trying to isolate the problem I noticed that this also happens with simpler controls like a LabelControl.

Things I tried are methods like Refresh(), Invalidate() and PerformLayout: they will not resolve the issue.

What does help is resizing the form. After that all controls are laid out correctly.

Can anyone help on how to solve this without resizing the form?

Attached a simple demo-project that illustrates the problem.

screenshot

Was it helpful?

Solution

From my comment above (seems really to be the problem here):

WinForms (and the GDI in general) is often behaving unpredictably if one tries to use coordinates outside a 16 bit range. Try to avoid that. In the range of possible problems are things just not getting drawn at all, OverflowExceptions at unexpected code positions etc.

OTHER TIPS

If it's possible to you take decision to change this layout, I suggest you to take another approach on showing/editing the documents chapters with some kind of pagination or collapsing RTF blocks into a menu and showing only current.

You see.. it makes a sense the height value be a integer 16-bit value. A screen is way more tiny than this. As panel height increases to such a high size. You see that using scroll bar will become very very sensible.. and it's not a good thing.

Content with size 2x, 3x, 5x being scrolled is usable to user. But scrolling a content with height (~32768) of at least (using good resolution monitor w/ window maximized) in optimal case 32x the size of window is very uncomfortable.

Plus, I believe that the productivity of user will decrease due to brain difficulty in locate "things" in a increasing collection of "things".

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top