Hello,
I need to set a focus to a nested parametrized. The action is placed on second tab and the focus should be set after choosing this tab.
Hello,
I need to set a focus to a nested parametrized. The action is placed on second tab and the focus should be set after choosing this tab.
Hi Pawel,
You can focus your action each time the Items tab is selected using the following code in your Win module:
C#using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Win;
using DevExpress.XtraBars;
using DevExpress.XtraBars.Controls;
using DevExpress.XtraBars.Utils;
using System;
using System.Linq;
using System.Windows.Forms;
using Xaf_18_1.Module.BusinessObjects;
using Xaf_18_1.Module.Controllers;
namespace Xaf_18_1.Module.Win.Controllers {
public class MyViewController : ObjectViewController<ObjectView, Item> {
protected override void OnActivated() {
base.OnActivated();
ItemController controller = Frame.GetController<ItemController>();
if (controller != null) {
controller.ItemAction.CustomizeControl += (s, e) => {
BarEditItem barEditItem = (BarEditItem)e.Control;
Action focus = () => {
WinWindow mainWindow = (WinWindow)((WinApplication)Application).MainWindow;
mainWindow.Form.BeginInvoke(new MethodInvoker(() => {
IDockableObject dockableObject = barEditItem.Manager.Bars[0];
DockedBarControl barControl = (DockedBarControl)dockableObject.BarControl;
BarItemLinkReadOnlyCollection visibleLinks = barControl.VisibleLinks;
BarItemLink link = visibleLinks.OfType<BarItemLink>().First(l => l.Item == barEditItem);
link.Focus();
}));
};
focus();
View.ControlsCreated += (sender, args) => {
Control control = (Control)View.Control;
control.VisibleChanged += (_, x) => {
focus();
};
};
};
}
}
}
}
If you need to focus it only if the tab is selected the first time, don't handle the ControlsCreated event.
Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.
Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.