Specifying the Control to Receive Focus

Using the SetFocus() Method

The mmBaseWindow class has a SetFocus method that sets focus to the specified element. If an element is not on a page of a TabControl, you can simply call its Focus method to set focus to it. However, if it's on a TabControl, you must first select the TabItem on which it resides (if it's not the currently selected TabItem) and then set focus to it. The MM .NET SetFocus method does all of this for you. It automatically detects if the specified element is on a TabItem page, and if so, it makes the TabItem the currently selected tab (if it's not already), and then sets focus to the element.

Here's an example of how to call this method:

In C#:

this.SetFocus(this.txtOrderID);

In VB .NET:

Me.SetFocus(Me.txtOrderID)

Focus Properties

The mmWindow class has several focus properties you can set in your window's constructor that specify which user interface element should receive focus when specific events occur in the Window. Here is the complete list:

  • FocusOnCancelElement - Specifies the UI element to get focus when changes to the window's primary business object are canceled

  • FocusOnGetElement - Specifies the UI element to get focus after entities have been retrieved in the window's primary business object

  • FocusOnLoadElement - Specifies the UI element to get focus when the window is first loaded

  • FocusOnNewElement - Specifies the UI element to get focus when a new entity is created in the window's primary business object

  • FocusOnSaveElement - Specifies the UI element to get focus after changes to the window's primary business object are saved

  • FocusOnDeleteElement - Specifies the UI element to get focus after a delete in the window's primary business object is performed

© (c) 2026 Oak Leaf Enterprises, Inc., 1996-2026 • Updated: 04/26/18
Comment or report problem with topic