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

2 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
    Admin
    Dess avatar
    1609 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. UI for WinForms is Visual Studio 2017 Ready
Back to Top