Null pointer exception with SetDockIcon where DockingManager on UserControl

I have seen a similar post (link below) but this is old and seemed not to be resolved:

http://www.syncfusion.co.in/support/forums/message.aspx?MessageID=30838

I'm using 4.4 and have reproduced the problem with the example in this post:

http://www.syncfusion.com/support/forums/message.aspx?MessageID=44345

Here the docking manager is held on a UserControl so to allow it to co-exist with the ToolStripContainer control. However, placing the following code:

Icon icon = new Icon(@"Redo.ico");
dockingManager1.SetDockIcon(treeView1, icon);

in the Constructor or OnLoad() method gives a null pointer.

I have used the SetDockIcon method successfully when I had the docking manager on a Form but since I need to follow the above example and use a UserControl, I've run into this problem.

Anything I'm doing wrong or is this a bug?

Thanks in advance,

Jas.

2 Replies

MU Murugan Syncfusion Team February 16, 2007 01:28 AM UTC

Hi James,

UserControl_OnLoad is not the correct place to do customization of DockingManager. Please refer to the below KB and let me know if it helps.

Is the Form.Load event handler a good place to perform custom initialization of the docking layout?


Code snippet:

private void dockingManager1_NewDockStateEndLoad(object sender, EventArgs e)
{
if (this.flag)
{
this.flag = false;
Icon iIcon = new Icon("App.ico");
this.dockingManager1.SetDockIcon(this.treeView1, iIcon);
}
}

Thank you for using Syncfusion products.

Regards,
Murugan P.S


AD Administrator Syncfusion Team February 16, 2007 11:34 AM UTC

Thanks for the reply. Although that method solved the problem for setting the icon at load up time, it didn't offer any help for programatically added panels since the event never fired again. Even if it did, it doesn't passed any information in the EventArgs (apart from a bool LoadResult) indicating which control I would need to set the icon on.

I'm not sure why but my problem has gone away - after the MainForm is loaded and the user clicks on something, programatically adding a docked control and setting it's icon now works. Why this is causing an exception before I don't know - the UserControl holding the DockingManager has moved projects so maybe there was a resource issue with the Icons...

I'll keep an eye on it and come back if it occurs again.

Thanks,

Jas.


Loader.
Up arrow icon