Current filter:
                                You should refresh the page.
                                Support Center
                                0
                                  • I have a treelist whose view intially has the NavigationStyle set to Row so the user sees a whole row selected as they move around it. The problem arises when a context menu setup is selected by the user to initiate a rename edit of the data of a specific column of the selected row. Similar to an F2 (if I could get it to work, but that is another issue).

                                    The context menu click event method initially sets the NavigationStyle to Cell and then attempts to set focus to the cell in question to allow for an edit by calling the views ShowEditor. Visually the row highlight goes away but the user is not placed into the cell nor are its contents highlighted to start the edit process. The user actually has to manually click inside the column to begin the edit.

                                    Now if I set the TreeListView's NavigationStyle to Cell in the Xaml initially, and then execute the context click, the cell gets the focus; albeit the I bar gets placed at the beginning. ???

                                    First off what can I do to get the cell focus selected when the initial state is Row, and secondly how can I get the text selected for the I-bar cursor edit?

                                    Attached is an example project created with VS2012 which targets 11.2 versions of the tools.

                                WPFTreeList.zip
                                • William Wegerson 07.02.2012

                                  Our company upgraded to 12.1 and I upgraded the test project to 12.1 and the same still happens.

                                You must  log in  or  register  to leave comments

                                1 Solution

                                0

                                Hi William,

                                Thank you for your patience. You can achieve this goal by using the Dispatcher.BeginInvoke method. In this method, restore the selected row and call the ShowEditor method. You can also handle the TableView.ShownEditor method to select all text in it.

                                For instance:

                                	
                                [C#]
                                private void renameItem_ItemClick(object sender, DevExpress.Xpf.Bars.ItemClickEventArgs e) { int i = tlMain.View.FocusedRowHandle; tlMain.View.NavigationStyle = GridViewNavigationStyle.Cell; Dispatcher.BeginInvoke(new Action(() => { tlMain.View.FocusedRowHandle = i; tlMain.View.FocusedColumn = tlMain.Columns.First(); tlMain.View.ShowEditor(); tlMain.View.ShownEditor += new DevExpress.Xpf.Grid.TreeList.TreeListEditorEventHandler(View_ShownEditor); })); } void View_ShownEditor(object sender, DevExpress.Xpf.Grid.TreeList.TreeListEditorEventArgs e) { tlMain.View.ShownEditor -= new DevExpress.Xpf.Grid.TreeList.TreeListEditorEventHandler(View_ShownEditor); tlMain.View.ActiveEditor.SelectAll(); }

                                If you have additional questions, feel free to reactivate this thread.

                                Thanks

                                • William Wegerson 07.02.2012

                                  Thanks,

                                  The dispatch code works. I only had to add the return to row selection after the edit such as:

                                  public int FocusedRowHandle { get; set; }

                                  private void renameItem_ItemClick( object sender, DevExpress.Xpf.Bars.ItemClickEventArgs e )
                                  {
                                      FocusedRowHandle = tlMain.View.FocusedRowHandle;

                                      tlMain.View.NavigationStyle = GridViewNavigationStyle.Cell;

                                      tlMain.View.CellValueChanged += View_CellValueChanged;

                                      Dispatcher.BeginInvoke( new Action( () =>
                                      {
                                          tlMain.View.FocusedRowHandle = FocusedRowHandle;
                                          tlMain.View.FocusedColumn = tlMain.Columns.First();
                                          tlMain.View.ShownEditor += new DevExpress.Xpf.Grid.TreeList.TreeListEditorEventHandler( View_ShownEditor );
                                          tlMain.View.ShowEditor();

                                      } ) );

                                  }

                                  void View_CellValueChanged( object sender, DevExpress.Xpf.Grid.TreeList.TreeListCellValueChangedEventArgs e )
                                  {
                                      tlMain.View.CellValueChanged -= View_CellValueChanged;
                                      tlMain.View.NavigationStyle = GridViewNavigationStyle.Row;
                                      tlMain.View.FocusedRowHandle = FocusedRowHandle;
                                  }

                                  void View_ShownEditor( object sender, DevExpress.Xpf.Grid.TreeList.TreeListEditorEventArgs e )
                                  {
                                      tlMain.View.ShownEditor -= new DevExpress.Xpf.Grid.TreeList.TreeListEditorEventHandler( View_ShownEditor );
                                      tlMain.View.ActiveEditor.SelectAll();
                                  }

                                You must  log in  or  register  to leave comments

                                To start a chat you should create a support ticket


                                If you need additional product information, write to us at info@devexpress.com or call us at +1 (818) 844-3383

                                FOLLOW US

                                DevExpress engineers feature-complete Presentation Controls, IDE Productivity Tools, Business Application Frameworks, and Reporting Systems for Visual Studio, along with high-performance HTML JS Mobile Frameworks for developers targeting iOS, Android and Windows Phone. Whether using WPF, Silverlight, ASP.NET, WinForms, HTML5 or Windows 8, DevExpress tools help you build and deliver your best in the shortest time possible.

                                Copyright © 1998-2014 Developer Express Inc.
                                All trademarks or registered trademarks are property of their respective owners