Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How to scroll a listview with scrollable property disabled

How to scroll a listview with scrollable property disabled

Scheduled Pinned Locked Moved C#
databasetutorialcareer
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vayanan
    wrote on last edited by
    #1

    Hi alll, How to scroll a listview with out scroll bar. I know

    ListBox1.EnsureVisible(index)

    will do the job, but since i have disabled Scrollable property using

    ListBox1.Scrollable = false

    EnsureVisible is not doing the job. is there any other way to scroll listview with scrollable propery set to false Regards Vayanans

    A L S 3 Replies Last reply
    0
    • V vayanan

      Hi alll, How to scroll a listview with out scroll bar. I know

      ListBox1.EnsureVisible(index)

      will do the job, but since i have disabled Scrollable property using

      ListBox1.Scrollable = false

      EnsureVisible is not doing the job. is there any other way to scroll listview with scrollable propery set to false Regards Vayanans

      A Offline
      A Offline
      AhsanS
      wrote on last edited by
      #2

      I don't think of any idea in c# windows application. But if you could explain your scenario a bit, perhaps i could be able to give you any suggestion.

      Ahsan Ullah Senior Software Engineer

      V 1 Reply Last reply
      0
      • V vayanan

        Hi alll, How to scroll a listview with out scroll bar. I know

        ListBox1.EnsureVisible(index)

        will do the job, but since i have disabled Scrollable property using

        ListBox1.Scrollable = false

        EnsureVisible is not doing the job. is there any other way to scroll listview with scrollable propery set to false Regards Vayanans

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        ..and why not resort to setting the scrollable for a second?

        bool oldVal = ListBox1.Scrollable;
        ListBox1.Scrollable = true;
        ListBox1.EnsureVisible(index);
        ListBox1.Scrollable = oldVal;

        1 Reply Last reply
        0
        • A AhsanS

          I don't think of any idea in c# windows application. But if you could explain your scenario a bit, perhaps i could be able to give you any suggestion.

          Ahsan Ullah Senior Software Engineer

          V Offline
          V Offline
          vayanan
          wrote on last edited by
          #4

          hi I dont want to use scroll bar to scroll the listview. i have two buttons for scrolling u and down is there is any way to do so...? Regards Vayanans

          A 1 Reply Last reply
          0
          • V vayanan

            hi I dont want to use scroll bar to scroll the listview. i have two buttons for scrolling u and down is there is any way to do so...? Regards Vayanans

            A Offline
            A Offline
            AhsanS
            wrote on last edited by
            #5

            you should make a user control like listview by using textboxes for example. Then put your own buttons for moving it up or down.

            Ahsan Ullah Senior Software Engineer

            1 Reply Last reply
            0
            • V vayanan

              Hi alll, How to scroll a listview with out scroll bar. I know

              ListBox1.EnsureVisible(index)

              will do the job, but since i have disabled Scrollable property using

              ListBox1.Scrollable = false

              EnsureVisible is not doing the job. is there any other way to scroll listview with scrollable propery set to false Regards Vayanans

              S Offline
              S Offline
              Simon P Stevens
              wrote on last edited by
              #6

              Put the list box on a panel. Make the list box tall enough to display all the items at the same time. Make you buttons move the list box up and down so what ever part of the panel you want visible can be seen in the panel. Here's a sample of what I mean using a label. Just create a new winforms app, and paste this over the form1 definition:

              public partial class Form1 : Form
              {
                  private System.Windows.Forms.Panel panel1;
                  private System.Windows.Forms.Label label1;
                  private System.Windows.Forms.Button button1;
                  private System.Windows.Forms.Button button2;
              
                  public Form1()
                  {
                      InitializeComponent();
              
                      // Create the controls.
                      this.panel1 = new System.Windows.Forms.Panel();
                      this.button1 = new System.Windows.Forms.Button();
                      this.button2 = new System.Windows.Forms.Button();
                      this.label1 = new System.Windows.Forms.Label();
              
                      // 
                      // panel1
                      // 
                      this.panel1.Controls.Add(this.label1);
                      this.panel1.Location = new System.Drawing.Point(93, 12);
                      this.panel1.Size = new System.Drawing.Size(60, 50);
                      this.panel1.TabIndex = 0;
                      // 
                      // button1
                      // 
                      this.button1.Location = new System.Drawing.Point(12, 12);
                      this.button1.Size = new System.Drawing.Size(75, 23);
                      this.button1.TabIndex = 0;
                      this.button1.Text = "Up";
                      this.button1.UseVisualStyleBackColor = true;
                      this.button1.Click += new System.EventHandler(this.scrollUp);
                      // 
                      // button2
                      // 
                      this.button2.Location = new System.Drawing.Point(12, 41);
                      this.button2.Size = new System.Drawing.Size(75, 23);
                      this.button2.TabIndex = 0;
                      this.button2.Text = "Down";
                      this.button2.UseVisualStyleBackColor = true;
                      this.button2.Click += new System.EventHandler(this.scrollDown);
                      // 
                      // label1
                      // 
                      this.label1.Location = new System.Drawing.Point(0, 0);
                      this.label1.Name = "label1";
                      this.label1.Size = new System.Drawing.Size(60, 186);
                      this.label1.TabIndex = 1;
                      this.label1.Text = "This is a label with some text that goes on for ages and ages to " +
                          "demonstrate how it is possible to manually scroll a control using a panel.";
              
              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups