Current filter:
                                You should refresh the page.
                                Support Center
                                0
                                  • Currently I do this in the code-behind of a window:

                                                if (e.LeftButton == MouseButtonState.Pressed)
                                                {
                                                    // drag and drop
                                                    int rowHandle = treeListView.GetRowHandleByMouseEventArgs(e);
                                                    if (rowHandle < 0)
                                                        return;

                                                    TreeListNode node = treeListView.GetNodeByRowHandle(rowHandle);

                                    I need to refactor this code to another location. I don't want to be passing MouseEventArgs around. Given a TreeListView and a Point where the user clicked, I want to be able to determine the TreeListNode or whatever other element the user clicked on.

                                    The documentation talks about doing hit testing with TreeListView.CalcHitInfo(), but that takes a dependency object as a parameter, I think this would be the opposite of my situation, where I need to know where something is (so...is that really hit testing?).

                                You must  log in  or  register  to leave comments

                                2 Solutions

                                Creation Date Rating Importance Sort by
                                0


                                To get Selected Row of TreeList :

                                [XAML]
                                <dxg:TreeListControl x:Name="treeListContacts" Cursor="Hand" AutoPopulateColumns="True" HorizontalAlignment="Left" Margin="10,19,0,0" VerticalAlignment="Top" Height="650" Width="180" Grid.RowSpan="2"> <dxg:TreeListControl.Columns> <dxg:TreeListColumn FieldName="CompanyID" ReadOnly="True" Width="30" Visible="False"/> <dxg:TreeListColumn FieldName="CompanyName" ReadOnly="True" Width="200" /> </dxg:TreeListControl.Columns> <dxg:TreeListControl.View> <dxg:TreeListView Name="treeListContactsInner" ShowTotalSummary="True" VerticalScrollbarVisibility="Hidden" HorizontalScrollbarVisibility="Hidden" ShowColumnHeaders="False" ShowExpandButtons="true" ShowHorizontalLines="False" ShowIndicator="False" ShowNodeImages="False" ShowFocusedRectangle="True" ShowRootIndent="true" ShowVerticalLines="False" FocusedRowChanged="TreeListView_FocusedRowChanged_1" PreviewMouseDown="treeListContactsInner_PreviewMouseDown" /> </dxg:TreeListControl.View> </dxg:TreeListControl>
                                [C#]
                                private void treeListContactsInner_PreviewMouseDown(object sender, MouseButtonEventArgs e) { var hi = treeListContactsInner.CalcHitInfo(e.OriginalSource as DependencyObject); if (hi.InRowCell) { TreeListNode clickedNode = treeListContactsInner.GetNodeByRowHandle(hi.RowHandle); //clickedNode.Content; VVIMP int i = 0; if (clickedNode.Content is Company) i = ((Company)clickedNode.Content).CompanyID; e.Handled = true; } if (hi.InNodeExpandButton) return; }
                                This worked for me..!

                                Thanks to all!

                                • Dmitry Tok (DevExpress Support) 05.21.2013

                                  Hello,
                                  Thank you for sharing your solution with us.
                                  I hope it will help our other customers.

                                You must  log in  or  register  to leave comments
                                0

                                Hi James,

                                Thank you for contacting us. To accomplish this task, you can use the following code:

                                [C#]
                                private void grid_MouseMove(object sender, MouseEventArgs e) { TreeListViewHitInfo hi = treeListView.CalcHitInfo(e.OriginalSource as DependencyObject); TreeListNode node = treeListView.GetNodeByRowHandle(hi.RowHandle); }

                                Please let us know whether or not you find this solution helpful.

                                Thanks
                                Dimitros

                                • Shekhar Shete 05.21.2013

                                  how to get the Selected row on single click on TreeListControl. Please provide sample code:

                                  [XAML]
                                  <dxg:TreeListControl x:Name="treeListContacts" Cursor="Hand" AutoPopulateColumns="True" HorizontalAlignment="Left" Margin="10,19,0,0" VerticalAlignment="Top" Height="650" Width="180" Grid.RowSpan="2"> <dxg:TreeListControl.Columns> <dxg:TreeListColumn FieldName="CompanyID" ReadOnly="True" Width="30" Visible="False"/> <dxg:TreeListColumn FieldName="CompanyName" ReadOnly="True" Width="200" /> </dxg:TreeListControl.Columns> <dxg:TreeListControl.View> <dxg:TreeListView ShowTotalSummary="True" VerticalScrollbarVisibility="Hidden" HorizontalScrollbarVisibility="Hidden" ShowColumnHeaders="False" ShowExpandButtons="true" ShowHorizontalLines="False" ShowIndicator="False" ShowNodeImages="False" ShowFocusedRectangle="True" ShowRootIndent="true" ShowVerticalLines="False" FocusedRowChanged="TreeListView_FocusedRowChanged_1" /> </dxg:TreeListControl.View> </dxg:TreeListControl>
                                  Help Appreciated!

                                  Thanks!

                                • Dmitry Tok (DevExpress Support) 05.21.2013

                                  Hello,
                                  As I see you've posted a similar question in the How to Get Selected Row Values/Column Value of WPF TreeListControl ?. So, let us continue discussing this issue in that thread.
                                  Thanks

                                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