Home Forums WPF controls Xceed DataGrid for WPF Force grid to scroll horizontally

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • User (Old forums)
    Post count: 23064
    #24642 |

    I have a form that allows users to dynamically add columns to a datagrid. However when the column added exceeds the viewable bounds of the grid, it doesn’t automatically scroll that column into view. How can I force a horizontal scroll to the last column added? I’ve tried BringIntoView and BringItemIntoView but both only seem to affect vertical scrolling.

    Imported from legacy forums. Posted by vbv1 (had 675 views)

    User (Old forums)
    Post count: 23064

    No response? Big surprise.

    Imported from legacy forums. Posted by vbv1 (had 326 views)

    Odi [Xceed]
    Post count: 426

    Xceed DataGrid for WPF is provided to you for free, but technical support, at any level, is not included. It should not be a big surprise at all. Only non-free Xceed controls receive free technical support in the forums and by email.

    The fact that most Xceed DataGrid for WPF forum posts do get responses is thanks to a growing community of users that help each other out, and thanks to the fact that Xceed’s developers take an active, but totally voluntary interest in providing answers. They love the product they are working on.


    Imported from legacy forums. Posted by Odi [Xceed] (had 431 views)

    Xceed Support
    Post count: 5658

    You will need to scroll manually the ScrollViewer to the appropriate position to have your column visible…

    The ScrollViewer can be accessed using this code:

    ScrollViewer myScrollViewer = myDataGridControl.Template.FindName( “PART_ScrollViewer”, myDataGridControl ) as ScrollViewer;

    You can then use the ScrollViewer.ScrollToRightEnd() to scroll to the horizontal right-end.

    Note: When you add a column to the grid, the grid will reset its content to include the newly added column, it is better to use the dispatcher to handle the “scrolling” in that particular case:

    myDataGridControl.Columns.Add( myNewColum );

    this.Dispatcher.BeginInvoke( DispatcherPriority.Loaded, delegate()
    { //Do the stuff written above here }

    Note2: This code was written without compiling it… Therefore, there might be some syntax errors… But the concepts behind the code are all tried, tested and true.

    Imported from legacy forums. Posted by Marcus [Xceed] (had 4069 views)

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.