Articles in this section
Category / Section

How to update the control states in Parent Form based on key inputs in Floating Form of WinForms Docking Manager?

1 min read

Method and event

In DockingManager, it is possible to update the control states of the Parent Form based on Key inputs in Floating Form by handling the Floating Form event named KeyDown and function named PerformClick in MenuStrip.

 

The following code example demonstrates the same.

C#

/// <summary>
/// Occurs when a key is pressed while the control has focus.
/// </summary>
void control2_KeyDown(object sender, KeyEventArgs e)
{
    if (e.Control && e.KeyCode == Keys.S)       // Ctrl-S Save
    {
         e.SuppressKeyPress = true; 
         string activeControl = _dockingManager.GetDockLabel(_dockingManager.ActiveControl);
         this.asdasdToolStripMenuItem.PerformClick();
    }
}

 

VB

''' <summary>
''' Occurs when a key is pressed while the control has focus.
''' </summary>
Private Sub control2_KeyDown(ByVal sender As Object, ByVal e As KeyEventArgs)
 If e.Control AndAlso e.KeyCode = Keys.S Then ' Ctrl-S Save
    e.SuppressKeyPress = True
    Dim activeControl As String = _dockingManager.GetDockLabel(_dockingManager.ActiveControl)
    Me.asdasdToolStripMenuItem.PerformClick()
 End If
End Sub

 

Update control states of the parent form

Figure 1.  Update control states of the Parent Form based on Key inputs in Floating Form with image

Samples:

 

C#: How to update controls states in DockingManager Parent Form, based on Key inputs in Floating Form?

 

VB: How to update controls states in DockingManager Parent Form, based on Key inputs in Floating Form?

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied