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

                                    Here is Markup:
                                     

                                    [XAML]
                                    <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.
                                    [C#]
                                    private void treeListContacts_FocusableChanged(object sender, DependencyPropertyChangedEventArgs e) { object id = treeListContacts.GetNodeValue(treeListContacts.FocusedNode, "CompanyId"); }
                                    Please View Details of this issue.

                                    Help appreciated!
                                    Thanks!

                                You must  log in  or  register  to leave comments

                                1 Solution

                                0

                                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:

                                [C#]
                                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:

                                  [XAML]
                                  <dxg:TreeListControl ItemsSource="{Binding OrdersList}" AutoPopulateColumns="True"> <dxg:TreeListControl.View> <dxg:TreeListView FocusedRowChanged="TreeListView_FocusedRowChanged_1"/> </dxg:TreeListControl.View> </dxg:TreeListControl>
                                  with this code:
                                  [C#]
                                  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?

                                • Dmitry Tok (DevExpress Support) 05.21.2013

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

                                  [C#]
                                  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.
                                  Thanks

                                • Shekhar Shete 05.21.2013

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

                                • Dmitry Tok (DevExpress Support) 05.21.2013

                                  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

                                  Hi,

                                  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.

                                You must  log in  or  register  to leave comments

                                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