This is a migrated thread and some comments may be shown as answers.

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

4 Answers 597 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Amilton
Top achievements
Rank 1
Amilton asked on 12 Jun 2015, 02:07 PM

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. 

 

 

​

4 Answers, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 15 Jun 2015, 02:39 PM
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
0
Jared
Top achievements
Rank 2
answered on 20 Dec 2018, 03:53 PM

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

 

myListView.ListViewElement.VerticalScrollState = ScrollState.AlwaysHide;
myListView.ListViewElement.HorizontalScrollState = ScrollState.AlwaysHide;     
0
Jared
Top achievements
Rank 2
answered on 20 Dec 2018, 03:55 PM

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;
0
Hristo
Telerik team
answered on 21 Dec 2018, 06:15 AM
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.
Tags
ListView
Asked by
Amilton
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Jared
Top achievements
Rank 2
Hristo
Telerik team
Share this question
or