Category / Section
How to change docking icon during run time in WinForms Docking Manager?
1 min read
Dock icon
DockingManager.SetDockIcon(control,Index number of the ImageList) method can change the icon during runtime.
The following code snippet Change the Icon by changing of Imagelist when button1 click event,
C#
private void button1_Click(object sender, System.EventArgs e) { //Here we Change the Docking Manager ImageList property from //ImageList1 to ImageList2 by alternatively if(dockingManager1.ImageList==this.imageList2) dockingManager1.ImageList=this.imageList1; else dockingManager1.ImageList=this.imageList2; } //Occurs when the ImageList property changes private void dockingManager1_ImageListChanged(object sender, System.EventArgs e) { //Here the code which set the Docking Icon dynamically. dockingManager1.SetDockIcon(this.panel1,0); dockingManager1.SetDockIcon(this.panel2,1); }
VB
Private Sub button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles button1.Click 'Here we Change the Docking Manager ImageList property from 'ImageList1 to ImageList2 by alternatively If dockingManager1.ImageList Is Me.imageList2 Then dockingManager1.ImageList=Me.imageList1 Else dockingManager1.ImageList=Me.imageList2 End If End Sub 'Occurs when the ImageList property changes Private Sub dockingManager1_ImageListChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles dockingManager1.ImageListChanged 'Here the code which set the Docking Icon dynamically. dockingManager1.SetDockIcon(Me.panel1,0) dockingManager1.SetDockIcon(Me.panel2,1) End Sub
Reference link: https://help.syncfusion.com/windowsforms/dockingmanager/docking-events#imagelistchanged-event