Welcome to the Xceed Community | Help
Community Search  
More Search Options

Vertical scrollbar in datagridcontrol

Sort Posts: Previous Next
  •  08-11-2009, 12:40 PM Post no. 23292

    Vertical scrollbar in datagridcontrol

    Hi, there

     Is there any way that I can get the vertical scrollbar in a datagrid control? Since I need to mannual scroll over the grid when some action is taken.

    Thanks,

    Ricky

  •  08-12-2009, 3:23 PM Post no. 23310 in reply to 23292

    Re: Vertical scrollbar in datagridcontrol

    Hi,

    You can get a hold of the vertical Scrollbar as follow:

    ScrollViewer sv = grid.Template.FindName( "PART_ScrollViewer", this.grid ) as ScrollViewer;
    ScrollBar verticalScrollBar = sv.Template.FindName( "PART_VerticalScrollBar", sv ) as ScrollBar;


    Xceed - Software Developer and Technical Support
  •  10-09-2009, 5:42 AM Post no. 24390 in reply to 23310

    Re: Vertical scrollbar in datagridcontrol

    Attachment: ScrollBarExample.zip

    I tried this in order to set the verticalScrollBar.Value property manually, but it results in the scrollbar becoming defunct and operating strangely.  The thumb no longer slides, but scrolling is still possible.  I've attached a simple example project demonstrating this odd behaviour.  Press the 'Test' button then try and slide the thumb on the vertical ScrollBar.

    Is this a bug - is there a solution?

    Thanks,

    Jason


    Associate, .NET Development
    Morgan Stanley, UK
  •  10-13-2009, 4:10 PM Post no. 24463 in reply to 24390

    Re: Vertical scrollbar in datagridcontrol

    This is a normal behaviour of the Scrollbar, it is not inherent to the Xceed Datagrid for WPF. To ensure yourself, you could use the ListBox as follow:

    private void btnTest_Click(object sender, RoutedEventArgs e)
            {
              ScrollViewer sv = Page1.GetScrollViewer( dgcMyData );
              ScrollBar verticalScrollBar = sv.Template.FindName( "PART_VerticalScrollBar", sv ) as ScrollBar;
              verticalScrollBar.Value = 45; // verticalScrollBar.Value;
            }

            public static ScrollViewer GetScrollViewer( ListBox listBox )
            {
              Border scroll_border = VisualTreeHelper.GetChild( listBox, 0 ) as Border;
              if( scroll_border is Border )
              {
                ScrollViewer scroll = scroll_border.Child as ScrollViewer;
                if( scroll is ScrollViewer )
                {
                  return scroll;
                }
                else
                {
                  return null;
                }
              }
              else
              {
                return null;
              }
            }

     

    The thumb will no longer move since its value is logically set on the ScrollViewer.


    Xceed - Software Developer and Technical Support
  •  10-13-2009, 5:06 PM Post no. 24467 in reply to 24463

    Re: Vertical scrollbar in datagridcontrol

    Ok, thanks for your clarification on that.  Is there any way of manually setting the scrollbar position then?

    According to http://msdn.microsoft.com/en-us/library/system.windows.controls.primitives.rangebase.value.aspx the value is a get/set property and that "the slider and scrollbar controls have a thumb that is synchronized with the Value of the control".

    Is there any way perhaps to get the thumb and set its value instead?


    Associate, .NET Development
    Morgan Stanley, UK
View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2011 Xceed Software Inc.