Current filter:
                                You should refresh the page.
                                  • Dear DevExpress Support,

                                    Please suggest how to focus the Full Text Search Box on ListView activation.

                                    The approach suggested in doesn't seem to work

                                    if (Frame.Template is DevExpress.ExpressApp.Win.Templates.MainForm) { BarManager manager = ((MainForm)Frame.Template).BarManager; manager.Items["Filter by Text"].PerformClick(); }

                                    Merry Christmas and a Happy New Year to you.

                                    Keep up the good work!

                                    Thank you.

                                • Aldagi 12.31.2013

                                  The above code does not work from an action either.

                                2 Solutions

                                Creation Date Importance Sort by


                                To accomplish this task, you can access the corresponding bar item, as shown in the How to: Customize Action Controls (WinForms) topic, and call the BarItemLink.Focus method at an appropriate moment. In addition, when the TabbedMDI mode is enabled, you need to use the BarItem.GetVisibleLinks method to obtain an appropriate BarItemLink. Note that this method will work in this scenario only starting with version 16.1.8.

                                To test it, include the Controller below into the YourSolutionName.Module.Win project and be sure to reference the DevExpress.XtraBars assembly:

                                using System; using DevExpress.XtraBars; using System.Windows.Forms; using DevExpress.ExpressApp; using DevExpress.Persistent.Base; using DevExpress.ExpressApp.Actions; using DevExpress.ExpressApp.Templates; using DevExpress.XtraBars.Docking2010; using DevExpress.ExpressApp.SystemModule; using DevExpress.ExpressApp.Win.Templates; using DevExpress.XtraBars.Docking2010.Views; using DevExpress.ExpressApp.Win.SystemModule; using DevExpress.ExpressApp.Templates.ActionControls; namespace MainDemo.Module.Win.Controllers { public class FocusFullTextSearchController : WindowController { private const string STR_ViewIdToBeFocused = "Contact_ListView"; private FilterController filterController; protected override void OnActivated() { base.OnActivated(); Frame.TemplateChanged += Frame_TemplateChanged; if (!IsMdiMode()) { filterController = Frame.GetController<FilterController>(); if(filterController != null) { filterController.FullTextFilterAction.Changed += FullTextFilterAction_Changed; } } } private bool IsContactListView(DevExpress.ExpressApp.View view) { return view != null && view.Id == STR_ViewIdToBeFocused; } private bool IsMdiMode() { UIType type = ((IModelOptionsWin)Application.Model.Options).UIType; return type == UIType.TabbedMDI || type == UIType.StandardMDI; } private void Frame_TemplateChanged(object sender, EventArgs e) { if(IsMdiMode() && Frame.Template is IXafDocumentsHostWindow) { ((IXafDocumentsHostWindow)Frame.Template).DocumentManager.ViewChanged += DocumentManager_ViewChanged; ((IXafDocumentsHostWindow)Frame.Template).DocumentManager.ViewChanging += DocumentManager_ViewChanging; } } private void DocumentManager_ViewChanging(object sender, ViewEventArgs args) { args.View.DocumentActivated -= View_DocumentActivated; } private void DocumentManager_ViewChanged(object sender, ViewEventArgs args) { args.View.DocumentActivated += View_DocumentActivated; } private static BarItem GetFullTextSearchBarItem(Form form) { IActionControlsSite site = form as IActionControlsSite; foreach(IActionControlContainer actionContainer in site.ActionContainers) { if(actionContainer.ActionCategory == PredefinedCategory.FullTextSearch.ToString()) { IActionControl actionControl = actionContainer.FindActionControl(FilterController.FullTextSearchActionId); if(actionControl != null) { return actionControl.NativeControl as BarItem; } } } return null; } private void View_DocumentActivated(object sender, DocumentEventArgs e) { IViewHolder viewHolder = e.Document.Form as IViewHolder; BarItem barItem = GetFullTextSearchBarItem(e.Document.Form); if(viewHolder != null && barItem != null && IsContactListView(viewHolder.View)) { FocusFullTextSearch(barItem); } } private void FullTextFilterAction_Changed(object sender, ActionChangedEventArgs e) { ActionBase action = sender as ActionBase; BarItem barItem = GetFullTextSearchBarItem(Frame.Template as Form); if(e.ChangedPropertyType == ActionChangedType.Active && action.Active && barItem != null && IsContactListView(Frame.View)) { FocusFullTextSearch(barItem); } } private void FocusFullTextSearch(BarItem barItem) { if(Application.MainWindow == null) { return; } ((Form)Application.MainWindow.Template).BeginInvoke(new MethodInvoker(() => { BarItemLinkReadOnlyCollection visibleLinks = barItem.GetVisibleLinks(); if(visibleLinks.Count > 0) { visibleLinks[0].Focus(); } })); } protected override void OnDeactivated() { base.OnDeactivated(); Frame.TemplateChanged -= Frame_TemplateChanged; if(Frame.Template is IXafDocumentsHostWindow) { ((IXafDocumentsHostWindow)Frame.Template).DocumentManager.ViewChanged -= DocumentManager_ViewChanged; ((IXafDocumentsHostWindow)Frame.Template).DocumentManager.ViewChanging -= DocumentManager_ViewChanging; } if(filterController != null) { filterController.FullTextFilterAction.Changed -= FullTextFilterAction_Changed; } } } }

                                This code supports the TabbedMDI, SingleSDI and MultipleWindowSDI UTType modes.

                                See Also:
                                How to focus a nested parametrized action

                                Show all comments
                                • P-C 01.18.2014

                                  Hello Dennis,
                                  Thank you for your reply.
                                  Your code does not seem to work when FormStyle is Standard and UIType is TabbedMDI in the provided sample.
                                  In fact, I'd be happy to see how to focus the filter editor from a controller or by a keyboard shortcut.
                                  Thank you.

                                • Dennis (DevExpress) 01.20.2014

                                  Hello Petre,
                                  Yes, this solution was designed and tested with the Standard and Ribbon modes when MultipleWindowSDI option is set. I tried to support the tabbed MDI mode as well, but could not do this in a reasonable time frame, I am afraid. We will consider updating the E807 example when a solution for this scenario is found. Your patience is highly appreciated.

                                • Aldagi 01.20.2014

                                  Thank you Dennis.

                                • Martin Praxmarer - DevExpress MVP 08.12.2016

                                  Hi Dennis - i am switching now to the new V2 templates - i am having now Problems to set the Focus to the fulltext? it there anything i should know? i tried your modified example above with ribbon / tabbed mdi?

                                • Alexey (DevExpress Support) 08.15.2016

                                  Hello Martin,
                                  We need additional time to prepare an answer. Please bear with us.

                                • Anatol (DevExpress Support) 08.15.2016

                                  This example will not work with a Tabbed MDI. We have already researched this issue and have found that the our bar items do not allow implementing this functionality - see Defaulting focus to full text search on newly opened root list views.

                                • Martin Praxmarer - DevExpress MVP 08.15.2016

                                  So what does that mean now Anatol? We have this funcionality for years now in our application - we cannot simply remove it?

                                • Martin Praxmarer - DevExpress MVP 08.15.2016
                                • Anatol (DevExpress Support) 08.16.2016

                                  Currently, our templates use BarLinkContainerExItem items as placeholders for action containers. Actions from an action container are added to this item. As I wrote in the An item from a merged BarLinkContainerExItem cannot be focused programmatically ticket, this bar item does not allow focusing merged bar items in code. Since the issue was reported for the second time, I have asked our developers to review this scenario once again. Currently, as a workaround, you can implement a custom action container that will not use the BarLinkContainerExItem item.

                                • Martin Praxmarer - DevExpress MVP 08.16.2016

                                  "Currently, as a workaround, you can implement a custom action container that will not use the BarLinkContainerExItem item." - thx Anatol  - i prefer waiting for your answer ;)

                                • Anatol (DevExpress Support) 08.17.2016

                                  Our developers have made changes required to support this scenario. Starting with version 16.1.6, it will be possible to use the BarItem.GetVisibleLinks method to get a BarItemLink that should be focused. I have attached an example to Dennis' answer. Note that this example will work only after the next update.

                                • Martin Praxmarer - DevExpress MVP 08.17.2016

                                  Perfect Anatol - thank you! Can i grab an hotfix for this?

                                • Anatol (DevExpress Support) 08.18.2016

                                  We are going to publish a hotfix with these changes at the end of this week. You can add the New Web UI - The Log On button is not focused by default ticket to your Favorites to be notified when the fix is ready and receive a download link.

                                • Martin Praxmarer - DevExpress MVP 08.22.2016

                                  Hi Anatol,

                                  i installed the hotfix - but GetVisibleLinks always Returns 0 ? i use tabbedmdi with ribbon?

                                • Martin Praxmarer - DevExpress MVP 08.22.2016

                                  Sorry Guys - was my fault - works perferct now!

                                  thank you!

                                • Anatol (DevExpress Support) 08.23.2016

                                  You are welcome!

                                • Nat (DevExpress) 09.19.2018


                                  We updated the solution to fix the issue described in the WinForms - NullReferenceException occurs in some circumstances in the code of the Q559647 ticket ticket.


                                • Aldagi 12.31.2013

                                  Thanks Martin for your quick reply and a proposed solution.
                                  Well, it works for when the FormStyle is Ribbon but fails when FormStyle is Standard, in the demo project itself.
                                  Any other ideas?
                                  Happy New Year to you!

                                • Martin Praxmarer - DevExpress MVP 12.31.2013

                                  sorry - as i never dealed with form style Standard, i cannot help much here, but i guess it should not much differ from the ribbon style!
                                  happy new year also to you!