Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DarkDockPanel add DarkDocument NullReferenceException within DarkControl #16

Open
merthsoft opened this issue Nov 25, 2019 · 3 comments

Comments

@merthsoft
Copy link

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.

@merthsoft
Copy link
Author

Note I was able to get past this by manually creating the objects and adding to the splitcontainer panel controls.

@RobinPerris
Copy link
Owner

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.

@merthsoft
Copy link
Author

merthsoft commented Nov 25, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants