I've taken over someone else's project and they have used Krypton Toolkit. When I change anything on the UI, (i.e., Add button, edit Text, add menu item), I get this exception error:
this.kryptonHeaderGroupMain.Controls.Add(this.kryptonHeaderGroupMain.Panel);
Cause an exception "ReadOnly controls collection"
..and it mucks up the Designer View.
What am I missing?
As some people recommended, I have tried it but still failed:
this.<kryptonControlsContainer>.Panel.Controls.Add(this.<otherControlName>);
The
Controls
property of theKryptonHeaderGroup
control is a custom Controls Collection (it's namedKryptonReadOnlyControls
) which doesn't allow adding or removing child controls. The wayKryptonHeaderGroup
was designed is that it has aPanel
which acts as the container for its child controls. What you need to do is as follows.In design-mode:
Before adding any controls, make sure you select the panel and not the
KryptonHeaderGroup
itself. See the difference in these screenshots:Using code:
Note: The same logic applies for other controls like
KryptonGroupBox
,KryptonGroup
, andKryptonSplitContainer
.