Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Scroll bars disappear when docked in TabPage

Posted on 2008-03-12
5
Medium Priority
?
7,935 Views
Last Modified: 2011-10-03
I have a dynamic TabControl that generates the tabPages on the fly, I have a user control that has a split container with a DataGridView displayed in SplitContainer.Panel2.  When I dock the user control in the TabPage the scrollbar for the DataGridView disapears.  I have used Microsofts Designer surface to try to recreate the problem with no luck.  I even mirrirored the auto generated designer.cs code Visual Studio generates.  I have tried sizing options, ancoring, nothing seems to get the scrollbars into view.
//generates the TabPage...
 
 
		public TabPage AddAutoPositionTabPage(String name, String text, int index)
		{
			TabPage tabPage = new System.Windows.Forms.TabPage();
			SplitContainer splitContainer = new System.Windows.Forms.SplitContainer();
 
			System.Windows.Forms.DataGridView dataGridView1 = new DataGridView();
			System.Windows.Forms.TableLayoutPanel panel1 = new TableLayoutPanel();
			System.Windows.Forms.TableLayoutPanel panel2 = new TableLayoutPanel();
			System.Windows.Forms.GroupBox groupBox1 = new GroupBox();
			System.Windows.Forms.GroupBox groupBox2 = new GroupBox();
			System.Windows.Forms.VScrollBar vScrollBar2 = new VScrollBar();
			System.Windows.Forms.VScrollBar vScrollBar1 = new VScrollBar();
 
			tabPage.SuspendLayout();
			splitContainer.Panel1.SuspendLayout();
			splitContainer.Panel2.SuspendLayout();
			splitContainer.SuspendLayout();
			groupBox1.SuspendLayout();
			((System.ComponentModel.ISupportInitialize)(dataGridView1)).BeginInit();
			groupBox2.SuspendLayout();
			panel1.SuspendLayout();
			panel2.SuspendLayout();
			SuspendLayout();
 
			splitContainer.SuspendLayout();
			
			// 
			// tabPage.1
			// 
			tabPage.Controls.Add(splitContainer);
			tabPage.Location = new System.Drawing.Point(4, 22);
			tabPage.Name = name;
 
			tabPage.Padding = new System.Windows.Forms.Padding(3);
			tabPage.Size = this.Size;//new System.Drawing.Size(489, 497);
			tabPage.TabIndex = 0;
			tabPage.Text = text;
			tabPage.UseVisualStyleBackColor = true;
			// 
			// splitContainer.1
			// 
 
			splitContainer.Dock = System.Windows.Forms.DockStyle.Fill;
			splitContainer.Location = new System.Drawing.Point(3, 3);
			splitContainer.Name = name + "_splitContainer";
			splitContainer.Orientation = System.Windows.Forms.Orientation.Horizontal;
			splitContainer.Size = this.Size;//new System.Drawing.Size(483, 491);
 
 
			// 
			// splitContainer1.Panel1
			// 
			splitContainer.Panel1.Controls.Add(dataGridView1);
			splitContainer.Panel1.Controls.Add(groupBox1);
			//splitContainer.Panel1.Controls.Add(panel2);
			// 
			// splitContainer1.Panel2
			// 
			splitContainer.Panel2.Controls.Add(groupBox2);
			//splitContainer.Panel2.Controls.Add(panel1);
			splitContainer.Size = this.Size;// new System.Drawing.Size(483, 491);
			splitContainer.SplitterDistance = 256;
			splitContainer.TabIndex = 0;
			// 
			// groupBox1
			// 
			groupBox1.Controls.Add(panel2);
			groupBox1.Dock = System.Windows.Forms.DockStyle.Top;
			groupBox1.Location = new System.Drawing.Point(0, 0);
			groupBox1.Name = name + "_groupBox1";
			groupBox1.Dock = DockStyle.Top;
			groupBox1.Size = new System.Drawing.Size(this.Width, 117);
			groupBox1.AutoSize = true;
			groupBox1.AutoSizeMode = AutoSizeMode.GrowOnly;
			groupBox1.TabIndex = 0;
			groupBox1.TabStop = false;
			groupBox1.Text = "Filter Section";
 
			// 
			// dataGridView1
			// 
			dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
			dataGridView1.Dock = System.Windows.Forms.DockStyle.Bottom;
			dataGridView1.Dock = DockStyle.Bottom;
			dataGridView1.Location = new System.Drawing.Point(0, 123);
			dataGridView1.Name = name + "_dataGridView1";
			dataGridView1.Size = new System.Drawing.Size(this.Width, 138);
			dataGridView1.TabIndex = 1;
			// 
			// groupBox2
			// 
			groupBox2.Controls.Add(panel1);
			groupBox2.Dock = DockStyle.Fill;
			groupBox2.Dock = System.Windows.Forms.DockStyle.Fill;
			groupBox2.Location = new System.Drawing.Point(0, 0);
			groupBox2.Name = name + "_groupBox2";
			groupBox2.Size = new System.Drawing.Size(this.Width, 226);
			groupBox2.AutoSize = true;
			groupBox2.AutoSizeMode = AutoSizeMode.GrowOnly;
			groupBox2.TabIndex = 0;
			groupBox2.TabStop = false;
			groupBox2.Text = "Detail View";
			// 
			// panel1
			// 
			panel1.AutoScroll = true;
			panel1.Dock = System.Windows.Forms.DockStyle.Fill;
			panel1.Dock = DockStyle.Fill;
			panel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, this.Width));
			//panel1.FlowDirection = FlowDirection.TopDown;
			panel1.Location = new System.Drawing.Point(3, 16);
			panel1.Name = name + "_panel1";
			panel1.Size = new System.Drawing.Size(this.Width, 207);
			panel1.MinimumSize = new System.Drawing.Size(477, 207);
			panel1.AutoSize = true;
			panel1.AutoSizeMode = AutoSizeMode.GrowOnly;
			panel1.TabIndex = 0;
 
			// 
			// panel2
			// 
			panel2.AutoScroll = true;
			panel2.Dock = System.Windows.Forms.DockStyle.Fill;
			panel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, this.Width));
			//panel1.FlowDirection = FlowDirection.TopDown;
			panel1.Dock = DockStyle.Fill;
			panel2.Location = new System.Drawing.Point(3, 16);
			panel2.Name = name + "_panel2";
			panel2.Size = new System.Drawing.Size(this.Width, 98);
			panel2.MinimumSize = new System.Drawing.Size(477, 98);
			panel2.AutoSize = true;
			panel2.AutoSizeMode = AutoSizeMode.GrowOnly;
			panel2.TabIndex = 0;
 
			AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
			AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
 
			if(index == -1)
				tabControl1.TabPages.Add(tabPage);
			else
				tabControl1.TabPages.Insert(index, tabPage);
 
			tabPage.ResumeLayout(false);
			splitContainer.Panel1.ResumeLayout(false);
			splitContainer.Panel2.ResumeLayout(false);
			splitContainer.ResumeLayout(false);
			groupBox1.ResumeLayout(false);
			((System.ComponentModel.ISupportInitialize)(dataGridView1)).EndInit();
			groupBox2.ResumeLayout(false);
			panel1.ResumeLayout(false);
			panel2.ResumeLayout(false);
			ResumeLayout(false);
 
			tabPage.Select();
 
			return tabPage;
		}
 
//Adds custom Tab
		private void addCustomTab(String tabName, XElement xCustom)
		{
			TabPage tp = new TabPage();
			
			this.SuspendLayout();
			
			tabControl1.TabPages.Add(tp);
 
			Control c = Generator.CreateUserControl(xCustom);
			tp.Controls.Add(c);
 
			tp.Location = new System.Drawing.Point(4, 22);
			tp.Padding = new System.Windows.Forms.Padding(3);
			tp.Size = new System.Drawing.Size(740, 597);
			tp.Name = tabName;
			tp.Text = tabName;
			tp.UseVisualStyleBackColor = true;
 
			c.Dock = DockStyle.Fill;
			c.Location = new System.Drawing.Point(3, 3);
			c.Size = new System.Drawing.Size(734, 591);
			c.TabIndex = 0;
 
			this.ResumeLayout();
		}

Open in new window

0
Comment
Question by:awykel
  • 3
  • 2
5 Comments
 
LVL 12

Expert Comment

by:ZachSmith
ID: 21109241
Which scrollbar disappears? The horizontal or the vertical one? Have you tried making the DataGridView so that it is docked to fill the panel?
0
 

Author Comment

by:awykel
ID: 21109309
The horozontal scroll bar at the bottom of the screen.  Yes I beleive everything is docked properly.

Outline on docking and anchoring:

Split container = Dock.Fill / (anchor Top,Left)
UserControl = Dock.Fill / (Anchor: None)
SplitContainer.Panel2 DataGridView = Dock.Fill / (anchor Top,Left)
SplitContainer.Panel1 Panel1 = Dock.Fill / (anchor Top,Left)
0
 

Author Comment

by:awykel
ID: 21109432
Okay I just learned this is a docking problem.  Perhaps I don't understand Microsoft .NET docking.

Seems the root of the problem is another user control where the TabControl is Dock.Fill and at the bottom there is aa button bar that is Dock.Bottom.

the problem is that the size of the TabControl = the Size of the UserControl

So the buttonBar is blocking the scrollBar.

I need help with Docking basics I guess.  Somethings in .NET seem intutive but turn out to scorn you in the end, does any one have any remedies?
0
 
LVL 12

Expert Comment

by:ZachSmith
ID: 21109493
I wrote this article on docking - perhaps it will help you:

http://articles.techrepublic.com.com/5100-3513-6165908.html
0
 

Accepted Solution

by:
awykel earned 0 total points
ID: 21109544
Found the solution.  Still would like an explination.  Seems that adding controls directory to the UserControl Class does not allow sizing events to get reported correctly so Docking doesn't work correctly.

The solution is to add a panel to the base userControl and then add all other controls to that base panel.
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
Loops Section Overview
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

876 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question