Current filter:
                                You should refresh the page.
                                Support Center
                                  • I have WPF DevExpress TreeListControl which is binded using Entity Framework. I want to get the values of "Selected Row" of

                                    Here is Markup:

                                    <dxg:TreeListControl x:Name="treeListContacts" Cursor="Hand" AutoPopulateColumns="True" HorizontalAlignment="Left" Margin="10,19,0,0" VerticalAlignment="Top" Height="650" Width="180" FocusableChanged="treeListContacts_FocusableChanged"> <dxg:TreeListControl.Columns> <dxg:TreeListColumn FieldName="CompanyID" ReadOnly="True" Width="30" Visible="False"/> <dxg:TreeListColumn FieldName="CompanyName" ReadOnly="True" /> </dxg:TreeListControl.Columns> <dxg:TreeListControl.View> <dxg:TreeListView ShowTotalSummary="True"/> </dxg:TreeListControl.View> </dxg:TreeListControl>
                                    I have tried the FocusableChanged Event but not able to get method GetNode() which doesnt work.
                                    private void treeListContacts_FocusableChanged(object sender, DependencyPropertyChangedEventArgs e) { object id = treeListContacts.GetNodeValue(treeListContacts.FocusedNode, "CompanyId"); }
                                    Please View Details of this issue.

                                    Help appreciated!

                                1 Solution

                                Creation Date Rating Importance Sort by

                                Hello Shekhar,
                                Your code is not clear to me. The FocusableChanged event is raised by the TreeListControl, but the GetNodeValue method and the FocusedNode property are TreeListView members. To make this code work, change it as follows:

                                object id = treeListContacts.View.GetNodeValue(treeListContacts.View.FocusedNode, "CompanyId");

                                Show all comments
                                • Shekhar Shete 05.15.2013

                                  where should i write this event in TreeListControl or TreeListView ?

                                • Your requirements are not clear to me.
                                  As far as I understand, you need to handle the event that is raised when a focused node is changed. I want to note that the FocusableChanged event is raised when the TreeListControl Focusable property is changed, not a focused node. To catch a new focused node value (for example, the "OrderID" one), handle the TreeListView FocusedRowChanged event:

                                  <dxg:TreeListControl ItemsSource="{Binding OrdersList}" AutoPopulateColumns="True"> <dxg:TreeListControl.View> <dxg:TreeListView FocusedRowChanged="TreeListView_FocusedRowChanged_1"/> </dxg:TreeListControl.View> </dxg:TreeListControl>
                                  with this code:
                                  private void TreeListView_FocusedRowChanged_1(object sender, FocusedRowChangedEventArgs e) { int id = int.MinValue; if (e.NewRow is Orders) id = ((Orders)e.NewRow).OrderID; }

                                • Shekhar Shete 05.16.2013

                                  Thanks Alexander this worked for me..! One more thing i want to ask. If their is only one item in TreeListView and click on row this event doesn't fire as TreeListView_FocusedRowChanged_1 event doesnt occure. So, is their any other event so that i can get the Row Values on Single Click?

                                • Hi Shekhar,

                                  In this case, I suggest that you handle the PreviewMouseDown event in order to calculate hit information and determine the clicked row. Please review the following documentation topic for more information: Hit Information.

                                • Shekhar Shete 05.21.2013

                                  Hi Alexander, thanks for replying! but i am not able to get the Selected row the given sample is for Grid and i am using TreeListControl will you provide some sample code for the above markup of TreeListControl that i have posted in this post?

                                • Hello Shekhar,
                                  You can handle the TreeListView.PreviewMouseDown event and use the following code snippet to get the clicked row value:

                                  private void view_PreviewMouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e) { var hi = view.CalcHitInfo(e.OriginalSource as DependencyObject); if (hi.InRowCell) { TreeListNode clickedNode = view.GetNodeByRowHandle(hi.RowHandle); //clickedNode.Content e.Handled = true; } if (hi.InNodeExpandButton) return; }
                                  In this case, the clickedNode.Content property value will contain an underlying data source object that was clicked. Please try the suggested approach and let us know of your results.

                                • Shekhar Shete 05.21.2013

                                  Hey Dmitry Tok!
                                  It works fine for me! This is Exactly what i need! Thanks a lot...!

                                • Hello,
                                  I'm glad to hear that my solution was helpful to you!
                                  Feel free to contact us if you have further questions.

                                • bill cole 12.16.2013

                                  I tried the above code for the selected index. However this does not work if I use keyboard navigation. Can you please guide me a solution where I can get the selected index in both the scenario (Keyboard as well as mouse).

                                • Ilya (DevExpress Support) 12.17.2013


                                  To make it work in both scenarios, you can handle the FocusedRowChanged event as Alexander suggested above in case the keyboard is used, and the approach Dmitry's suggested in case the mouse is used.

                                  Feel free to contact us if you need additional clarification.

                                If you need additional product information, write to us at 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, ASP.NET, WinForms, HTML5 or Windows 10, DevExpress tools help you build and deliver your best in the shortest time possible.

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