|
-
July 28th, 2009, 04:47 AM
#1
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
-
July 28th, 2009, 04:49 AM
#2
Re: SplitContainer panel scroll bar.
can you put your code here so that it would be easy to identify your mistake
-
July 28th, 2009, 04:52 AM
#3
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)
{
}
}
}
-
July 29th, 2009, 03:58 AM
#4
Re: SplitContainer panel scroll bar.
Any solution for this.... :-(
-
July 29th, 2009, 05:17 AM
#5
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 !
-
August 10th, 2009, 04:16 AM
#6
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|