Current filter:
                                You should refresh the page.
                                  • Hi Guys,

                                    we have some problems when setting EnableAutoTabOrder to false, and set TabIndex by hand for some editors. The problem comes when the detailview has disabled editors because of some conditional appearance. we know that AllowFocusReadonlyEditors is by default false, and thats the wanted behaviour. but the problem is that the defined tabIndex has no effect when the editor becomes active - see attached video. after the editor is enabled, the tabindex should be reflected by the layout control. our users reported that this worked in past versions, and started to happening after the latest updates.

                                    demo code for maindemo contact detailview:

                                            protected override void OnViewControlsCreated()

                                                var layoutControl = this.View.Control as LayoutControl;
                                                layoutControl.OptionsFocus.EnableAutoTabOrder = false;
                                                var items = this.View.GetItems<PropertyEditor>();

                                                ((Control)items.First(p => p.PropertyName == "FirstName").Control).TabIndex = 0;
                                                ((Control)items.First(p => p.PropertyName == "MiddleName").Control).TabIndex = 1;
                                                ((Control)items.First(p => p.PropertyName == "LastName").Control).TabIndex = 2;
                                                ((Control)items.First(p => p.PropertyName == "Notes").Control).TabIndex = 3;

                                • Andrey K (DevExpress Support) 09.16.2019

                                  This question seems to be more related to the Layout control engine than to XAF, so I am passing it to our WinForms team. Please await our response.

                                1 Solution

                                Creation Date Importance Sort by

                                Hello Noxe,
                                I checked the "c:\Program Files (x86)\DevExpress 19.1\Components\Sources\DevExpress.XtraLayout\DevExpress.XtraLayout\Helpers\FocusHelper.cs" and related source code and could not find that it handled a scenario with dynamically disabled or enabled editors when EnableAutoTabOrder is set to False. XtraLayoutControl developers confirmed this as well. When EnableAutoTabOrder is set to False, you take the full responsibility on how tab stops are managed and the AllowFocusReadOnlyEditors option has no effect here.
                                Anyway, it does not seem difficult to implement this functionality on your own. I have attached a modified MainDemo project where I demonstrated a possible way to do this in simple scenarios. Of course, this sample can be extended to handle other scenarios - feel free to modify it as your business needs dictate.
                                Take special note of the following

                                • I removed your OnViewControlsCreated method as it is not recommended for accessing PropertyEditor controls (due to delayed view item initialization).
                                • It is important to set the BaseEdit.TabStop, because it overrides the default Control.TabStop behavior.
                                • I specify the TabIndex in the Application Model extension (required values must be set to values greater or equal to 0 manually).
                                using DevExpress.ExpressApp; using System; using DevExpress.ExpressApp.Win.Layout; using DevExpress.ExpressApp.Editors; using DevExpress.XtraEditors; using DevExpress.ExpressApp.Model; using System.Windows.Forms; using MainDemo.Module.BusinessObjects; using System.ComponentModel; namespace MainDemo.Module.Win.Controllers { public class CustomWinController : ObjectViewController<DevExpress.ExpressApp.DetailView, Contact>, IModelExtender { protected override void OnActivated() { base.OnActivated(); View.LayoutManager.LayoutCreated += this.LayoutManager_LayoutCreated; ((WinLayoutManager)View.LayoutManager).ItemCreated += this.WinLayoutManager_ItemCreated; } private void LayoutManager_LayoutCreated(object sender, EventArgs e) { ((WinLayoutManager)sender).Container.OptionsFocus.EnableAutoTabOrder = false; } private void WinLayoutManager_ItemCreated(object sender, ItemCreatedEventArgs e) { PropertyEditor editor = e.ViewItem as PropertyEditor; if(e.ModelLayoutElement is IModelLayoutItemTabIndex && editor != null) { int tabIndex = ((IModelLayoutItemTabIndex)e.ModelLayoutElement).TabIndex; if(tabIndex > -1) { Control control = editor.Control as Control; if(control != null) { SetTabIndex(control, tabIndex); SetTabStop(control as Control, editor.AllowEdit.ResultValue); } else { editor.ControlCreated += (s1, e1) => { var editor1 = (PropertyEditor)s1; SetTabIndex(editor1.Control as Control, tabIndex); SetTabStop(editor1.Control as Control, editor1.AllowEdit.ResultValue); }; editor.AllowEditChanged += (s2, e2) => { var editor2 = (PropertyEditor)s2; SetTabStop(editor2.Control as Control, editor2.AllowEdit.ResultValue); }; } } } } protected virtual void SetTabIndex(Control control, int tabIndex) { if(control != null) { control.TabIndex = tabIndex; } } protected virtual void SetTabStop(Control control, bool enabled) { BaseEdit baseEdit = control as BaseEdit; if(baseEdit != null) { baseEdit.TabStop = enabled; } else { control.TabStop = enabled; } } protected override void OnDeactivated() { if(View.LayoutManager != null) { View.LayoutManager.LayoutCreated -= this.LayoutManager_LayoutCreated; } base.OnDeactivated(); } public void ExtendModelInterfaces(ModelInterfaceExtenders extenders) { extenders.Add<IModelViewLayoutElement, IModelLayoutItemTabIndex>(); } } public interface IModelLayoutItemTabIndex { [DefaultValue(-1)] int TabIndex { get; set; } } }
                                • Martin Praxmarer - DevExpress MVP 09.23.2019

                                  Hi Dennis,

                                  thx for the update - in our application we of course handle this scenario a bit different - so the above code was just for demonstration purpose ;) I think the confusing thing was that our users reported this as it started with the latest updates - but thats a different story ;)

                                  in our case we also set the TabStop property based on the model, and the defaultvalue is always True. so for now we will update our code and use the AllowEditChanged event, but we will also investigate further if that worked on an earlier version before.

                                • Dennis (DevExpress) 09.24.2019

                                  Thank you, Noxe. Please keep us posted of your results.

                                • Martin Praxmarer - DevExpress MVP 09.25.2019

                                  Hi man,

                                  just as info - we testet this with an older version of our applicatino - which used devex 18.1.5 - here it definitly worked. when the editor was disabled, no tabstop was made, when the editor got enabled, tabstop worked correctly.

                                  anyway - i can live with the AllowEditChanged event and manually adjust the TabStop property!

                                • Dennis (DevExpress) 09.25.2019

                                  Hi Noxe,
                                  I tested my XAF sample with v18.1.5 and readonly state changes were SOMETIMES handled there.
                                  However, even in v18.1.5 it does not work stably, for instance, after disabling or enabling editors for the second time. Refer to the project and video attached.
                                  Neither XAF nor XtraLayoutControl team had special code, tests or documentation to guarantee this functionality back then and in the latest version. It worked by accident, and I do not recommend you rely on this. If you want a reliable solution, the AllowEditChanged event handler is the best choice here. Let us know if you experience any difficulties with this solution.
                                  Anyway, the XtraLayoutControl team is aware of your scenario and will take it into account.

                                • Martin Praxmarer - DevExpress MVP 09.25.2019

                                  thx man - yes, further testing today showed that it was not really stable - so we alredy extended our controller to make use of the AllowEditChanged event, works fine now! :)

                                  thx for your assistance!