Null reference exception using SetDockIcon
Hello, I am attempting to assign an icon to a docked control during the initialization process. Note, I am using the System.Drawing.Icon overload. When I do this, I get the following exception:
An unhandled exception of type ''System.NullReferenceException'' occurred in syncfusion.tools.windows.dll
Additional information: Object reference not set to an instance of an object.
The code I am using, looks like this:
// Note, I''ve extended the DockingManager, so "this" is the DockingManager.
this.DockControl(control, this.Parent, dockStyle, initialSize);
this.SetDockLabel(control, labelControl.Label);
System.Drawing.Icon icon = this.appContainer.GetImageIcon(labelControl.IconList, labelControl.IconName);
if (icon != null) this.SetDockIcon(control, icon);
I would appreciate any help or insight into this matter.
Thanks, Mike
SIGN IN To post a reply.
6 Replies
AD
Administrator
Syncfusion Team
June 28, 2005 12:49 PM UTC
Hi Mike,
I tested for this issue here but was not able to reproduce your problem. I have attached the sample used for testing. Please let me know if you are able to reproduce the problem using the test sample.
Also,Let me know if you have any questions regarding this.
Thanks,
Vijay.
>Hello, I am attempting to assign an icon to a docked control during the initialization process. Note, I am using the System.Drawing.Icon overload. When I do this, I get the following exception:
>
>An unhandled exception of type ''System.NullReferenceException'' occurred in syncfusion.tools.windows.dll
>
>Additional information: Object reference not set to an instance of an object.
>
>The code I am using, looks like this:
>
>// Note, I''ve extended the DockingManager, so "this" is the DockingManager.
>this.DockControl(control, this.Parent, dockStyle, initialSize);
>this.SetDockLabel(control, labelControl.Label);
>System.Drawing.Icon icon = this.appContainer.GetImageIcon(labelControl.IconList, labelControl.IconName);
>if (icon != null) this.SetDockIcon(control, icon);
>
>I would appreciate any help or insight into this matter.
>
>Thanks, Mike
AD
Administrator
Syncfusion Team
June 28, 2005 01:05 PM UTC
Hi Mike,
I just forgot to attach the sample in my previous response.
http://syncfusion.net/ExternalSupport/Tools/2005/June/F20876AHTabBackColor.zip
Thanks,
Vijay
>Hello, I am attempting to assign an icon to a docked control during the initialization process. Note, I am using the System.Drawing.Icon overload. When I do this, I get the following exception:
>
>An unhandled exception of type ''System.NullReferenceException'' occurred in syncfusion.tools.windows.dll
>
>Additional information: Object reference not set to an instance of an object.
>
>The code I am using, looks like this:
>
>// Note, I''ve extended the DockingManager, so "this" is the DockingManager.
>this.DockControl(control, this.Parent, dockStyle, initialSize);
>this.SetDockLabel(control, labelControl.Label);
>System.Drawing.Icon icon = this.appContainer.GetImageIcon(labelControl.IconList, labelControl.IconName);
>if (icon != null) this.SetDockIcon(control, icon);
>
>I would appreciate any help or insight into this matter.
>
>Thanks, Mike
MW
Mike Witt
June 28, 2005 03:34 PM UTC
Hi Vijay,
I tried your example and it worked without a problem. My situation is a bit different. Our custom docking manager is responsible for querying some configuration settings and it enables docking for the controls and sets the attributes (such as labels, icons, etc.). This all works, except for the icon. I have changed your Form1.cs to show you what I mean.
Thanks for your help... Mike
F20876AHTabBackColor-Mike_7534.zip
>
>Hi Mike,
> I just forgot to attach the sample in my previous response.
> http://syncfusion.net/ExternalSupport/Tools/2005/June/F20876AHTabBackColor.zip
>
>Thanks,
>Vijay
>
>>Hello, I am attempting to assign an icon to a docked control during the initialization process. Note, I am using the System.Drawing.Icon overload. When I do this, I get the following exception:
>>
>>An unhandled exception of type ''System.NullReferenceException'' occurred in syncfusion.tools.windows.dll
>>
>>Additional information: Object reference not set to an instance of an object.
>>
>>The code I am using, looks like this:
>>
>>// Note, I''ve extended the DockingManager, so "this" is the DockingManager.
>>this.DockControl(control, this.Parent, dockStyle, initialSize);
>>this.SetDockLabel(control, labelControl.Label);
>>System.Drawing.Icon icon = this.appContainer.GetImageIcon(labelControl.IconList, labelControl.IconName);
>>if (icon != null) this.SetDockIcon(control, icon);
>>
>>I would appreciate any help or insight into this matter.
>>
>>Thanks, Mike
MW
Mike Witt
July 6, 2005 05:11 PM UTC
Hi Vijay,
Just wondering if you had a chance to look at the code changes I made to demonstrate what we are doing? This is still a problem for us and if you have any other ideas ... I''d certainly appreciate hearing about them.
Mike
AD
Administrator
Syncfusion Team
July 6, 2005 10:10 PM UTC
Hi Mike
I have a quick look to your code:
The two panels are not in the controls collection of Form1. These methods will fail:
this.SetAutoHideMode(control, true);
this.SetDockIcon(control,icon);
Switch the Syncfusion environment to the Debug mode and you''ll see the asserts.
Furthermore, I have to check the DesignMode, otherwise the code is executing when the form opens in the designer. The path is different in the design/runtime mode, so an exception will be thrown.
private void dockingManager1_NewDockStateEndLoad(object sender, System.EventArgs e)
{
//this.dockingManager1.SetAutoHideMode(this.pnlpanel1, true);
if( !this.DesignMode )
{
this.dockingManager1.CustomSetDockIcon(this.pnlpanel2 , new Icon("..\\..\\sftools.ico"));
this.dockingManager1.CustomSetDockIcon(this.pnlpanel1 , new Icon("..\\..\\sftools.ico"));
}
}
Regards,
Thomas
>Hi Vijay,
>
>Just wondering if you had a chance to look at the code changes I made to demonstrate what we are doing? This is still a problem for us and if you have any other ideas ... I''d certainly appreciate hearing about them.
>
>Mike
MW
Mike Witt
July 7, 2005 01:30 PM UTC
Hi Thomas,
Thanks for your suggestions, I will look. The code your are looking at is my reworking of Vijay''s example to show how we are doing this, so it is not my actual code (which is more complicated).
I would not have a problem with the icon paths as I''m using an image list and generating the icon from there. Setting everything else on the docking manager works without a problem. Here is my actual code if you would be willing to take a look:
// Look for children to put in as tabbed controls
int counter=0;
foreach (HISOFTControlInfo controlInfo in parentPanel.ChildControlList.Values)
{
System.Windows.Forms.Control child = controlInfo.Control as System.Windows.Forms.Control;
if (controlInfo.InitialSize > 0) initialSize = controlInfo.InitialSize;
configControl.LastChildLink = controlInfo;
if (counter == 0)
{
this.DockControl(child, parentControl, dockStyle, initialSize);
}
else
{
this.DockControl(child, parentControl, DockingStyle.Tabbed, initialSize);
}
this.SetDockLabel(child, controlInfo.Label);
System.Drawing.Icon icon = this.appContainer.GetImageIcon(controlInfo.IconList, controlInfo.IconName);
if (icon != null) this.SetDockIcon(child, icon);
parentControl = child;
this.SetAutoHideMode(child, parentPanel.IsHidden);
this.SetCloseButtonVisibility(child, false);
counter++;
}
Thanks for any help! Mike
SIGN IN To post a reply.
- 6 Replies
- 2 Participants
-
MW Mike Witt
- Jun 24, 2005 02:44 PM UTC
- Jul 7, 2005 01:30 PM UTC