RadRepeatButton to scroll

9 posts, 1 answers
  1. Bryan Brannon
    Bryan Brannon avatar
    65 posts
    Member since:
    Aug 2012

    Posted 24 Jan 2008 Link to this post

    Is it possible to use the RadRepeat button to scroll a RadPanel or any controls that have the standard scrolling functionality:  Grid, ListBox.

    I have a touchscreen application and need the scroll bar buttons to be oversized.
  2. Angel
    Admin
    Angel avatar
    121 posts

    Posted 25 Jan 2008 Link to this post

    Hi Bryan Brannon,

    Yes, it is possible. Most of the controls can be scrolled by using the Win32 API SendMessage() to send WM_VSCROLL or WM_HSCROLL messages to the control's handle.

    However, for our controls that have RadScrollBars it is possible to scroll in a better way.
    You can find the examples below for vertical scrolling.

    For RadListBox:

    Handler for ScrollUp:
    Point newValue = this.radListBox1.ListBoxElement.Value;  
    newValue.Y -this.radListBox1.ListBoxElement.VerticalScrollBar.SmallChange;  
    if (newValue.Y < this.radListBox1.ListBoxElement.MinValue.Y)  
        newValue.Y = this.radListBox1.ListBoxElement.MinValue.Y;  
     
    this.radListBox1.ListBoxElement.Value = newValue

    Handler for ScrollDown:
    Point newValue = this.radListBox1.ListBoxElement.Value;  
    newValue.Y += this.radListBox1.ListBoxElement.VerticalScrollBar.SmallChange;  
    int maxVisualValue = this.radListBox1.ListBoxElement.MaxValue.Y -  
        this.radListBox1.ListBoxElement.VerticalScrollBar.LargeChange + 1;  
    if (newValue.Y > maxVisualValue)  
        newValue.Y = maxVisualValue;  
     
    this.radListBox1.ListBoxElement.Value = newValue

    The horizontal scrolling can be achieved by using X instead of Y members of the values.

    For RadGridView:

    Handler for ScrollUp:
    RadScrollBarElement verticalScrollBar =
        (RadScrollBarElement)((GridTableElement)this.radGridView1.GridElement).Children[3];  
                  
    int newValue = verticalScrollBar.Value - verticalScrollBar.SmallChange;  
    if (newValue >= verticalScrollBar.Minimum)  
        verticalScrollBar.Value = newValue;  
    else  
        verticalScrollBarverticalScrollBar.Value = verticalScrollBar.Minimum; 

    Handler for ScrollDown:
    RadScrollBarElement verticalScrollBar =
        (RadScrollBarElement)((GridTableElement)this.radGridView1.GridElement).Children[3];  
     
    int newValue = verticalScrollBar.Value + verticalScrollBar.SmallChange;  
    int maxVisualValue = verticalScrollBar.Maximum - verticalScrollBar.LargeChange + 1;  
    if (newValue <= maxVisualValue)  
        verticalScrollBar.Value = newValue;  
    else  
        verticalScrollBar.Value = maxVisualValue

    The horizontal ScrollBar of RadGridView can be obtained with the following code:
    RadScrollBarElement horizontalScrollBar =
        (RadScrollBarElement)((GridTableElement)this.radGridView1.GridElement).Children[4]; 

    I hope this helps. Please contact me again, if you need further assistance.

    Regards,
    Angel
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Bryan Brannon
    Bryan Brannon avatar
    65 posts
    Member since:
    Aug 2012

    Posted 25 Jan 2008 Link to this post

    Thank you for the quick response.

    I assume that the RadListBox and RadGridView are the only two that will allow for the "better way" of scrolling.  If for instance I wanted to scroll a RadPanel... I would need to use the Win32 API using the SendMessage().
  5. Answer
    Angel
    Admin
    Angel avatar
    121 posts

    Posted 25 Jan 2008 Link to this post

    Hi Bryan,

    Yes, you will have to use SendMessage(). I tried to use VerticalScroll.Value for RadPanel (and for Microsoft's Panel) but the scrollbar and the content of the panel were not synchronized well.

    I would like to note that all our scrollable controls use RadScrollBar and can be scrolled easily with managed code. Only RadPanel scrolls like Microsoft's Panel and cannot be scrolled easy.

    We plan to switch RadPanel to use RadScrollBars in one of the next major releases (no deadline is set as of now).

     
    Best wishes,
    Angel
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  6. Santiago Aragones
    Santiago Aragones avatar
    2 posts
    Member since:
    Jan 2008

    Posted 05 May 2008 Link to this post

    Hi,

    There is an easy way to make default win scrollbars to work? I forced them to show on a RadGridView but they just didn't do anything. I'm using your examples to make them work, but i still have to work its behavior.

    When will be the best moment (loading, painting,...) to get radscrollbars values to set them on win ones?

    Can i do the same for a RadTreeView (the next control i have to override its scrollbars)?

    Thx.
  7. Angel
    Admin
    Angel avatar
    121 posts

    Posted 07 May 2008 Link to this post

    Hello Santiago Aragones,

    If you want to use MS scrollbars instead of ours in RadGridView or RadTreeView, you have to do the following:
    1. Get the internal radscrollbars

      For RadTreeView you can get them this way:

      this.verticalScroll = this.radTreeView1.Controls[0] as RadVScrollBar;     
      this.horizontalScroll = this.radTreeView1.Controls[1] as RadHScrollBar; 
    2. Handle the Scroll or ValueChanged event of the MS scrollbars. For vertical scrolling, you can use code such as this one:

      this.radTreeView1.ScrollBy(e.OldValue-e.NewValue); 

      There is no specialized method for horizontal scrolling so you will need more code for it:

      if (this.radTreeView1.IsEditing)  
      {  
          this.radTreeView1.EndEdit(true);  
      }  
      this.radTreeView1.ScrollPosition = new Point(-e.NewValue, this.radTreeView1.ScrollPosition.Y);  
      this.radTreeView1.TreeViewElement.PositionOffset = new SizeF(-e.NewValue, 0); 
       
    3. Synchronize the outlook of the MS scrollbars with the internal ones - handle the ScrollParameterChanged event of the element:

      this.verticalScroll = this.radTreeView1.Controls[0] as RadVScrollBar;     
      this.horizontalScroll = this.radTreeView1.Controls[1] as RadHScrollBar; 

      and use code such as this one:

      void scrollParameterChanged(object sender, EventArgs e)     
      {     
          RadScrollBarElement srollElement = (RadScrollBarElement)sender;     
          ScrollBarParameters parameters = srollElement.GetParameters();     
          if (srollElement.ScrollType == ScrollType.Vertical)     
          {     
              this.vScrollBar1.Minimum = parameters.Minimum;     
              this.vScrollBar1.Maximum = parameters.Maximum;     
              this.vScrollBar1.SmallChange = parameters.SmallChange;     
              this.vScrollBar1.LargeChange = parameters.LargeChange;     
          }     
          else     
          {     
              this.hScrollBar1.Minimum = parameters.Minimum;     
              this.hScrollBar1.Maximum = parameters.Maximum;     
              this.hScrollBar1.SmallChange = parameters.SmallChange;     
              this.hScrollBar1.LargeChange = parameters.LargeChange;     
          }     

    External scrolling in the case of RadGridView was described in an earlier post.

    I hope this helps. Contact me again if you need further assistance.

    Regards,
    Angel
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  8. Santiago Aragones
    Santiago Aragones avatar
    2 posts
    Member since:
    Jan 2008

    Posted 08 May 2008 Link to this post

    thx, i already succeded.
  9. Craig
    Craig avatar
    2 posts
    Member since:
    Jan 2011

    Posted 12 Jan 2011 Link to this post

    Do you have the VB.net code for managing a gridview with radscrollbars?

    I've tried working out the conversion to no avail.

    Many Thanks
     
  10. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 14 Jan 2011 Link to this post

    Hi Craig,

    Thank you for writing.

    Please refer to this help article which demonstrates the scrolling functionality in RadGridView. 

    I hope you find this information helpful.

    If there is anything else I can assist you with, do not hesitate to contact me back with more details of your scenario.
     
    Best wishes,
    Stefan
    the Telerik team
    Q3’10 SP1 of RadControls for WinForms is available for download; also available is the Q1'11 Roadmap for Telerik Windows Forms controls.
Back to Top
UI for WinForms is Visual Studio 2017 Ready