DarkUI
DarkUI copied to clipboard
DarkDockPanel add DarkDocument NullReferenceException within DarkControl
I have a DarkDockPanel, and within it there is a split control. When I try to add an additional DarkDockPanel to the split control panel, I get the following exception:
---------------------------
Microsoft Visual Studio
---------------------------
Failed to create component 'DarkDockPanel'. The error message follows:
'System.NullReferenceException: Object reference not set to an instance of an object.
at DarkUI.Docking.DarkDockRegion.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.ControlCollection.Add(Control value)
at System.Windows.Forms.Design.ParentControlDesigner.AddChildControl(Control newChild)
at System.Windows.Forms.Design.ParentControlDesigner.AddControl(Control newChild, IDictionary defaultValues)
at System.Windows.Forms.Design.ControlDesigner.InitializeNewComponent(IDictionary defaultValues)
at System.Drawing.Design.ToolboxItem.CreateComponentsCore(IDesignerHost host, IDictionary defaultValues)
at System.Drawing.Design.ToolboxItem.CreateComponents(IDesignerHost host, IDictionary defaultValues)
at Microsoft.VisualStudio.Design.Toolbox.AutoToolboxManagerService.ToolboxManagerTool...'
---------------------------
OK
---------------------------
It appears you cannot add a DarkDockPanel to a DarkControl.
Note I was able to get past this by manually creating the objects and adding to the splitcontainer panel controls.
DarkDockPanel
is not meant to be nested. You should only ever have one. It is the parent control which contains all the regions, panels, drag areas, etc.
You can follow a step-by-step on how to configure it here: https://github.com/RobinPerris/DarkUI/wiki/Tabbed-document-interface
If that doesn't help solve the problem you face, can you explain what you're trying to achieve with your current control hierarchy? I might be able to come up with a solution that works with DarkUI.
Basically the structure I have is this
MainForm
is a DarkForm
MainForm
has a DarkDockPanel
called mainPanel
mainPanel
gets a DarkDocument
I created called UserAdminControl
UserAdminControl
has a SplitContainer
in it.
SplitContainer.Panel2
has a DarkDockPanel
called dock
dock
gets a DarkDocument
I created called RoleAssignmentControl
When I try to drag-and-drop the DarkDockPanel onto the SplitContainer.Panel2 from the designer I get the error message above. However, if I do it grammatically there are no errors:
var dock = new DarkDockPanel
{
Dock = DockStyle.Fill
};
splitContainer1.Panel2.Controls.Clear();
splitContainer1.Panel2.Controls.Add(dock);
var roleControl = new RoleAssignmentControl();
dock.AddContent(roleControl);
So ultimately I'm able to work around this, just not from the designer.