CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Feb 2006
    Posts
    20

    Angry SplitContainer panel scroll bar.

    I have a split container on the form. On the left panel and right panel I have tree views. I have set the tree view scroll bars to false. When the treeviews increase in size, tthe panels doesn't show any scroll bar even though autoscroll property of the panels are set to true. How can I show the scroll bars of the panel? I need to synchronise both the scroll bars later.

    Regards
    Surya

  2. #2
    Join Date
    May 2009
    Location
    Bengaluru, India
    Posts
    460

    Re: SplitContainer panel scroll bar.

    can you put your code here so that it would be easy to identify your mistake

  3. #3
    Join Date
    Feb 2006
    Posts
    20

    Re: SplitContainer panel scroll bar.

    Here is my code

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;

    namespace Scrollbar1
    {
    public partial class Form1 : Form
    {
    TreeView tv1 = new TreeView();
    TreeView tv2 = new TreeView();
    System.Windows.Forms.VScrollBar VScrollBar1 = new VScrollBar();
    public Form1()
    {
    InitializeComponent();
    this.splitContainer1.Panel2.AutoScroll = true;
    this.splitContainer1.Panel1.AutoScroll = true;
    this.splitContainer1.Panel1.VerticalScroll.Visible = true;
    this.splitContainer1.Panel2.VerticalScroll.Visible = true;
    //this.splitContainer1.Panel1.VerticalScroll.Maximum = this.splitContainer1.Panel2.VerticalScroll.Maximum;
    //splitContainer1.Panel2.Scroll += new ScrollEventHandler(splitContainer1_Scroll);
    }



    private void Add_Click(object sender, EventArgs e)
    {
    int intCounter;

    for (intCounter = 0; intCounter < 60; intCounter++)
    {
    tv1.Nodes.Add(Convert.ToString(intCounter));
    }
    splitContainer1.Panel1.Controls.Add(tv1);


    for (intCounter = 0; intCounter < 100; intCounter++)
    {
    tv2.Nodes.Add(Convert.ToString(intCounter));
    }

    splitContainer1.Panel2.Controls.Add(tv2);

    tv1.Dock = DockStyle.Fill;
    tv2.Dock = DockStyle.Fill;

    tv1.Scrollable = false;
    tv2.Scrollable = false;

    splitContainer1.Panel1.AutoScroll = true;
    splitContainer1.Panel2.AutoScroll = true;
    }

    private void splitContainer1_Panel2_Scroll(object sender, ScrollEventArgs e)
    {
    this.splitContainer1.Panel1.VerticalScroll.Value = e.NewValue;
    }

    private void splitContainer1_Scroll(object sender, ScrollEventArgs e)
    {
    if (e.ScrollOrientation == ScrollOrientation.VerticalScroll)
    {
    splitContainer1.Panel1.VerticalScroll.Value = e.NewValue;
    }
    }

    private void Form1_Load(object sender, EventArgs e)
    {


    }

    private void Form1_Resize(object sender, EventArgs e)
    {
    tv1.Dock = DockStyle.Top;
    tv1.Dock = DockStyle.Top;
    splitContainer1.Panel2.ScrollControlIntoView(tv2);
    }

    private void splitContainer1_SplitterMoved(object sender, SplitterEventArgs e)
    {

    }
    }
    }

  4. #4
    Join Date
    Feb 2006
    Posts
    20

    Re: SplitContainer panel scroll bar.

    Any solution for this.... :-(

  5. #5
    Join Date
    May 2009
    Location
    Bengaluru, India
    Posts
    460

    Re: SplitContainer panel scroll bar.

    Code:
    is.splitContainer1.Panel2.AutoScroll = true;
    this.splitContainer1.Panel1.AutoScroll = true;
    this.splitContainer1.Panel1.VerticalScroll.Visible = true;
    this.splitContainer1.Panel2.VerticalScroll.Visible = true;
    Here you are setting "true" to the visible flag for vertical scroll bar and for Autoscroll you are not setting it for the flag but directly assigning to the Autoscroll variable - Is this correct, verify once !

  6. #6
    Join Date
    Feb 2006
    Posts
    20

    Angry Re: SplitContainer panel scroll bar.

    Thanks for pointing it. Now I have changed it to


    this.splitContainer1.Panel2.AutoScroll = true;
    this.splitContainer1.Panel1.AutoScroll = true;
    //this.splitContainer1.Panel1.VerticalScroll.Visible = true;
    //this.splitContainer1.Panel2.VerticalScroll.Visible = true;
    this.splitContainer1.Panel1.VerticalScroll.Maximum = this. splitContainer1. Panel2. VerticalScroll . Maximum;

    But now the vertical scroll bar are invisible. Even though the treeview height is more than the panel height the scroll bars are not visible.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured