Automatic Vertical ScrollBar Visibility to radListView, radLiscControl and Windows listView [Resolved]

5 posts, 0 answers
  1. Amilton
    Amilton avatar
    4 posts
    Member since:
    Mar 2014

    Posted 12 Jun 2015 Link to this post

    Hello.

     I've been researching and made a code that could solve my problem of automatic visibility of the scroll bar in Telerik listView, Telerik ListControl and Windows listView

    using System;
     
    namespace TelerikWinFormsApp2
    {
        public partial class RadForm1 : Telerik.WinControls.UI.RadForm
        {
            public RadForm1()
            {
                InitializeComponent();
      
                for (int i = 0; i < 50; i++)
                {
                    radListView1.Items.Add("aa");
                    radListControl1.Items.Add("aa");
                    listView1.Items.Add("aa");
                }
     
                //Windows listView Mouse Events
                listView1.MouseEnter += new EventHandler(listView1_MouseEnter);
                listView1.MouseLeave += new EventHandler(listView1_MouseLeave);
     
                //Telerik listView Mouse Events
                radListView1.MouseEnter += new EventHandler(radListView1_MouseEnter);
                radListView1.MouseLeave += new EventHandler(radListView1_MouseLeave);
     
                //Telerik listControl Mouse Events
                radListControl1.MouseEnter += new EventHandler(radListControl1_MouseEnter);
                radListControl1.MouseLeave += new EventHandler(radListControl1_MouseLeave);
     
            }
     
            private void RadForm1_Load(object sender, EventArgs e)
            {
                //Windows ListView
                listView1.Scrollable = false;
     
                //Telerik ListView
                this.radListView1.ListViewElement.ViewElement.Scroller.Scrollbar.FirstButton.Visibility = Telerik.WinControls.ElementVisibility.Hidden;
                this.radListView1.ListViewElement.ViewElement.Scroller.Scrollbar.SecondButton.Visibility = Telerik.WinControls.ElementVisibility.Hidden;
                this.radListView1.ListViewElement.ViewElement.Scroller.Scrollbar.ThumbElement.Visibility = Telerik.WinControls.ElementVisibility.Hidden;
                this.radListView1.ListViewElement.ViewElement.Scroller.Scrollbar.FillElement.Visibility = Telerik.WinControls.ElementVisibility.Hidden;
                this.radListView1.ListViewElement.ViewElement.Scroller.Scrollbar.Children[1].Visibility = Telerik.WinControls.ElementVisibility.Hidden;
                this.radListView1.ListViewElement.ViewElement.Scroller.Scrollbar.BorderElement.Visibility = Telerik.WinControls.ElementVisibility.Hidden;
     
                //Telerik ListControl
                this.radListControl1.ListElement.Scroller.Scrollbar.FirstButton.Visibility = Telerik.WinControls.ElementVisibility.Hidden;
                this.radListControl1.ListElement.Scroller.Scrollbar.SecondButton.Visibility = Telerik.WinControls.ElementVisibility.Hidden;
                this.radListControl1.ListElement.Scroller.Scrollbar.ThumbElement.Visibility = Telerik.WinControls.ElementVisibility.Hidden;
                this.radListControl1.ListElement.Scroller.Scrollbar.FillElement.Visibility = Telerik.WinControls.ElementVisibility.Hidden;
                this.radListControl1.ListElement.Scroller.Scrollbar.Children[1].Visibility = Telerik.WinControls.ElementVisibility.Hidden;
                this.radListControl1.ListElement.Scroller.Scrollbar.BorderElement.Visibility = Telerik.WinControls.ElementVisibility.Hidden;
            }
     
            private void radListView1_MouseEnter(object sender, EventArgs e)
            {
                this.radListView1.ListViewElement.ViewElement.Scroller.Scrollbar.FirstButton.Visibility = Telerik.WinControls.ElementVisibility.Visible;
                this.radListView1.ListViewElement.ViewElement.Scroller.Scrollbar.SecondButton.Visibility = Telerik.WinControls.ElementVisibility.Visible;
                this.radListView1.ListViewElement.ViewElement.Scroller.Scrollbar.ThumbElement.Visibility = Telerik.WinControls.ElementVisibility.Visible;
                this.radListView1.ListViewElement.ViewElement.Scroller.Scrollbar.FillElement.Visibility = Telerik.WinControls.ElementVisibility.Visible;
                this.radListView1.ListViewElement.ViewElement.Scroller.Scrollbar.Children[1].Visibility = Telerik.WinControls.ElementVisibility.Visible;
                this.radListView1.ListViewElement.ViewElement.Scroller.Scrollbar.BorderElement.Visibility = Telerik.WinControls.ElementVisibility.Visible;
            }
     
            private void radListView1_MouseLeave(object sender, EventArgs e)
            {
                this.radListView1.ListViewElement.ViewElement.Scroller.Scrollbar.FirstButton.Visibility = Telerik.WinControls.ElementVisibility.Hidden;
                this.radListView1.ListViewElement.ViewElement.Scroller.Scrollbar.SecondButton.Visibility = Telerik.WinControls.ElementVisibility.Hidden;
                this.radListView1.ListViewElement.ViewElement.Scroller.Scrollbar.ThumbElement.Visibility = Telerik.WinControls.ElementVisibility.Hidden;
                this.radListView1.ListViewElement.ViewElement.Scroller.Scrollbar.FillElement.Visibility = Telerik.WinControls.ElementVisibility.Hidden;
                this.radListView1.ListViewElement.ViewElement.Scroller.Scrollbar.Children[1].Visibility = Telerik.WinControls.ElementVisibility.Hidden;
                this.radListView1.ListViewElement.ViewElement.Scroller.Scrollbar.BorderElement.Visibility = Telerik.WinControls.ElementVisibility.Hidden;
            }
     
            private void radListControl1_MouseEnter(object sender, EventArgs e)
            {
                this.radListControl1.ListElement.Scroller.Scrollbar.FirstButton.Visibility = Telerik.WinControls.ElementVisibility.Visible;
                this.radListControl1.ListElement.Scroller.Scrollbar.SecondButton.Visibility = Telerik.WinControls.ElementVisibility.Visible;
                this.radListControl1.ListElement.Scroller.Scrollbar.ThumbElement.Visibility = Telerik.WinControls.ElementVisibility.Visible;
                this.radListControl1.ListElement.Scroller.Scrollbar.FillElement.Visibility = Telerik.WinControls.ElementVisibility.Visible;
                this.radListControl1.ListElement.Scroller.Scrollbar.Children[1].Visibility = Telerik.WinControls.ElementVisibility.Visible;
                this.radListControl1.ListElement.Scroller.Scrollbar.BorderElement.Visibility = Telerik.WinControls.ElementVisibility.Visible;
            }
     
            private void radListControl1_MouseLeave(object sender, EventArgs e)
            {
                this.radListControl1.ListElement.Scroller.Scrollbar.FirstButton.Visibility = Telerik.WinControls.ElementVisibility.Hidden;
                this.radListControl1.ListElement.Scroller.Scrollbar.SecondButton.Visibility = Telerik.WinControls.ElementVisibility.Hidden;
                this.radListControl1.ListElement.Scroller.Scrollbar.ThumbElement.Visibility = Telerik.WinControls.ElementVisibility.Hidden;
                this.radListControl1.ListElement.Scroller.Scrollbar.FillElement.Visibility = Telerik.WinControls.ElementVisibility.Hidden;
                this.radListControl1.ListElement.Scroller.Scrollbar.Children[1].Visibility = Telerik.WinControls.ElementVisibility.Hidden;
                this.radListControl1.ListElement.Scroller.Scrollbar.BorderElement.Visibility = Telerik.WinControls.ElementVisibility.Hidden;
            }
     
            private void listView1_MouseEnter(object sender, EventArgs e)
            {
                listView1.Scrollable = true;
            }
     
            private void listView1_MouseLeave(object sender, EventArgs e)
            {
                listView1.Scrollable = false;
            }
        }
             
    }

     

    I hope it helps.

     

    Regards
    Felipe. 

     

     

  2. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3559 posts

    Posted 15 Jun 2015 Link to this post

    Hello Felipe,

    Thank you for sharing you solution with the community.

    I have updated your Telerik points for your efforts.

    Regards,

    Dess
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. Jared
    Jared avatar
    19 posts
    Member since:
    Oct 2015

    Posted 20 Dec 2018 Link to this post

    Seems as though newer version of the RadListView control make this easier.

     

    myListView.ListViewElement.VerticalScrollState = ScrollState.AlwaysHide;
    myListView.ListViewElement.HorizontalScrollState = ScrollState.AlwaysHide;     
  4. Jared
    Jared avatar
    19 posts
    Member since:
    Oct 2015

    Posted 20 Dec 2018 in reply to Jared Link to this post

    Although I'd argue this should work as well but it doesn't unfortunately.  It is often hard to find which of the visual elements you need to set when dealing with WinForms Telerik controls.  

    myListView.AutoScroll = false;
  5. Hristo
    Admin
    Hristo avatar
    1510 posts

    Posted 21 Dec 2018 Link to this post

    Hello Jared,

    Our controls are using special scrollbar elements so that they can be themed. The inherited scrollbar are usually not used at all. Depending on the element hierarchy of the control one can access the RadScrollbarElements from the visual tree. For example, you can check the element hierarchy of the pdf viewer control, here: https://docs.telerik.com/devtools/winforms/controls/pdfviewer/structure/visual-structure. I can also suggest using the RadControlSpy tool to inspect the elements.

    Let me know if you have other questions.

    Regards,
    Hristo
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top