)
We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to update WinForms TabbedMDIManager child forms icon when parent form icon is updated?

Platform: WinForms |
Control: TabbedMDIManager |
Published Date: April 30, 2011 |
Last Revised Date: January 29, 2020

Update the MDI child form icon

In TabbedMDIManager, it is possible to update the icon of the MDI Child form when the icon of the Main Form is changed. This can be achieved by updating the Icon of TabbedMDI child forms, after the Icon of the Main form changed.

C#

// logic to set the icon on the MDITabPanel
MDITabPanel mdiTabPanel = this.tabbedMDIManager1.GetTabHostFromForm(form).MDITabPanel;
TabPageAdv tabPage = mdiTabPanel.GetTabPageAdvFromForm(form);
// get the icon from the form
Icon ico = this.Icon;
// add the icon to the image list
// notice the call to ToBitmap, I think this where the problem is.
mdiTabPanel.ImageList.Images[tabPage.ImageIndex] = ico.ToBitmap();
mdiTabPanel.Invalidate();
mdiTabPanel.Update();

VB

' logic to set the icon on the MDITabPanel
Dim mdiTabPanel As MDITabPanel = Me.tabbedMDIManager1.GetTabHostFromForm(form).MDITabPanel
Dim tabPage As TabPageAdv = mdiTabPanel.GetTabPageAdvFromForm(form)
' get the icon from the form
Dim ico As Icon = Me.Icon
' add the icon to the image list
' notice the call to ToBitmap, I think this where the problem is.
mdiTabPanel.ImageList.Images(tabPage.ImageIndex) = ico.ToBitmap()
mdiTabPanel.Invalidate()
mdiTabPanel.Update() 

Screenshot

Before updating the child form icon when parent form icon changed with image

Figure 1. Before updating the Child form icon when Parent form icon changed with image.

After updating the child form icon when parent form icon changed with image

Figure 2. After updating the Child form icon when Parent form icon changed with image.

Samples:

C#: How to Update Child form icon when Parent form icon is changed C#

VB: How to Update Child form icon when Parent form icon is changed VB

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon