Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

splitter probs: what am i doing wrong? 1

Status
Not open for further replies.

dushkin

Programmer
Mar 28, 2002
90
US
Hi. I have spent the better half of the day tring to get this splitter to work on my form. not sure what i am doing wrong. i have 2 panels, each with components on them. I want the splitter to rest between each panel. Also, is there a way that C# provides to make this splitter "clickable"?? THanks much in advance, code below:



public class MyForm : System.Windows.Forms.Form
{
private Panel leftpanel;
private Panel rightpanel;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.StatusBar statusBar1;
private System.Windows.Forms.RichTextBox richTextBox1;
private System.Windows.Forms.RichTextBox richTextBox2;
private System.Windows.Forms.TreeView treeView2;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Splitter splitter1;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;

public MyForm()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();

//
// TODO: Add any constructor code after InitializeComponent call
//
}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.leftpanel = new System.Windows.Forms.Panel();
this.label1 = new System.Windows.Forms.Label();
this.richTextBox2 = new System.Windows.Forms.RichTextBox();
this.richTextBox1 = new System.Windows.Forms.RichTextBox();
this.button1 = new System.Windows.Forms.Button();
this.rightpanel = new System.Windows.Forms.Panel();
this.treeView2 = new System.Windows.Forms.TreeView();
this.statusBar1 = new System.Windows.Forms.StatusBar();
this.splitter1 = new System.Windows.Forms.Splitter();
this.leftpanel.SuspendLayout();
this.rightpanel.SuspendLayout();
this.SuspendLayout();
//
// leftpanel
//
this.leftpanel.Anchor = System.Windows.Forms.AnchorStyles.None;
this.leftpanel.BackColor = System.Drawing.Color.Aqua;
this.leftpanel.Controls.Add(this.label1);
this.leftpanel.Controls.Add(this.richTextBox2);
this.leftpanel.Controls.Add(this.richTextBox1);
this.leftpanel.Controls.Add(this.button1);
this.leftpanel.Location = new System.Drawing.Point(0, 0);
this.leftpanel.Name = "leftpanel";
this.leftpanel.Size = new System.Drawing.Size(312, 328);
this.leftpanel.TabIndex = 0;
//
// label1
//
this.label1.BackColor = System.Drawing.Color.Aqua;
this.label1.Location = new System.Drawing.Point(0, 0);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(288, 24);
this.label1.TabIndex = 8;
this.label1.Text = "Support for: Microsoft: Windows";
//
// richTextBox2
//
this.richTextBox2.Location = new System.Drawing.Point(16, 32);
this.richTextBox2.Name = "richTextBox2";
this.richTextBox2.Size = new System.Drawing.Size(296, 240);
this.richTextBox2.TabIndex = 7;
this.richTextBox2.Text = "";
//
// richTextBox1
//
this.richTextBox1.Location = new System.Drawing.Point(8, 278);
this.richTextBox1.Name = "richTextBox1";
this.richTextBox1.Size = new System.Drawing.Size(232, 40);
this.richTextBox1.TabIndex = 6;
this.richTextBox1.Text = "";
//
// button1
//
this.button1.Location = new System.Drawing.Point(248, 280);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(56, 40);
this.button1.TabIndex = 5;
this.button1.Text = "Send";
//
// rightpanel
//
this.rightpanel.Anchor = System.Windows.Forms.AnchorStyles.None;
this.rightpanel.BackColor = System.Drawing.Color.Beige;
this.rightpanel.Controls.Add(this.treeView2);
this.rightpanel.Location = new System.Drawing.Point(322, 0);
this.rightpanel.Name = "rightpanel";
this.rightpanel.Size = new System.Drawing.Size(184, 320);
this.rightpanel.TabIndex = 1;
//
// treeView2
//
this.treeView2.ImageIndex = -1;
this.treeView2.Location = new System.Drawing.Point(8, 8);
this.treeView2.Name = "treeView2";
this.treeView2.Nodes.AddRange(new System.Windows.Forms.TreeNode[] {
new System.Windows.Forms.TreeNode("NodeA", new System.Windows.Forms.TreeNode[] {
new System.Windows.Forms.TreeNode("ChildA"),
new System.Windows.Forms.TreeNode("ChildB")}),
new System.Windows.Forms.TreeNode("NodeB", new System.Windows.Forms.TreeNode[] {
new System.Windows.Forms.TreeNode("NodeC"),
new System.Windows.Forms.TreeNode("ChildB")}),
new System.Windows.Forms.TreeNode("NodeC", new System.Windows.Forms.TreeNode[] {
new System.Windows.Forms.TreeNode("ChildC"),
new System.Windows.Forms.TreeNode("ChildX")}),
new System.Windows.Forms.TreeNode("NodeE"),
new System.Windows.Forms.TreeNode("NodeF"),
new System.Windows.Forms.TreeNode("NodeG"),
new System.Windows.Forms.TreeNode("NodeH")});
this.treeView2.SelectedImageIndex = -1;
this.treeView2.Size = new System.Drawing.Size(168, 304);
this.treeView2.TabIndex = 0;
//
// statusBar1
//
this.statusBar1.Location = new System.Drawing.Point(8, 327);
this.statusBar1.Name = "statusBar1";
this.statusBar1.Size = new System.Drawing.Size(512, 22);
this.statusBar1.TabIndex = 2;
this.statusBar1.Text = "statusBar1";
//
// splitter1
//
this.splitter1.BackColor = System.Drawing.SystemColors.Desktop;
this.splitter1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.splitter1.Dock = System.Windows.Forms.DockStyle.Right;
this.splitter1.Location = new System.Drawing.Point(308, 0);
this.splitter1.Name = "splitter1";
this.splitter1.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
this.splitter1.Size = new System.Drawing.Size(12, 349);
this.splitter1.TabIndex = 2;
this.splitter1.TabStop = false;
//
// MyForm
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(520, 349);
this.Controls.Add(this.leftpanel);
this.Controls.Add(this.splitter1);
this.Controls.Add(this.rightpanel);
this.Name = "MyForm";
this.Text = "MyForm";
this.leftpanel.ResumeLayout(false);
this.rightpanel.ResumeLayout(false);
this.ResumeLayout(false);

}
#endregion

}
}
 
you need to make panel1 (the panel on the left) docked to the left, the splitter also dock to the left and panel2 (the panel on the right) needs to have the dock property to fill.

its not clickable if you mean that when you click on it it closes

Christiaan Baes
Belgium
&quot;What a wonderfull world&quot; - Louis armstrong
 
I've gived up with Splitters long time ago.
Try to use the Anchor property of the objecs, experiment with it a little and you will have more satisfaction then using a splitter.

________
George, M
Searches(faq333-4906),Carts(faq333-4911)
 
Hi. thanks for responding. i did that but the splitter still won't move. also, when i change its location values in the properties menu they default back to 0,0 when i hit return. how do i get the splitter to actually move?? thanks again in advance.
 
shaddow: thanks for the suggestion. I
know how to anchor objects but don't know how
to acheive the splitter effect without a splitter.
could you elaborate on that?
thanks again.
 
Here is a working sample of what I think you are trying to achieve.

Apologies in advance for posting a ton of code.
Code:
public class MyForm : System.Windows.Forms.Form
		{
			private Panel leftpanel;
			private Panel rightpanel;
			private System.Windows.Forms.Button button1;
			private System.Windows.Forms.StatusBar statusBar1;
			private System.Windows.Forms.RichTextBox richTextBox1;
			private System.Windows.Forms.RichTextBox richTextBox2;
			private System.Windows.Forms.TreeView treeView2;
			private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Panel panel1;
		private System.Windows.Forms.Splitter splitter1;
			/// <summary>
			/// Required designer variable.
			/// </summary>
			private System.ComponentModel.Container components = null;

			public MyForm()
			{
				//
				// Required for Windows Form Designer support
				//
				InitializeComponent();

				//
				// TODO: Add any constructor code after InitializeComponent call
				//
			}
        
			/// <summary>
			/// Clean up any resources being used.
			/// </summary>
			protected override void Dispose( bool disposing )
			{
				if( disposing )
				{
					if(components != null)
					{
						components.Dispose();
					}
				}
				base.Dispose( disposing );
			}

			#region Windows Form Designer generated code
			/// <summary>
			/// Required method for Designer support - do not modify
			/// the contents of this method with the code editor.
			/// </summary>
			private void InitializeComponent()
			{
				this.leftpanel = new System.Windows.Forms.Panel();
				this.label1 = new System.Windows.Forms.Label();
				this.richTextBox2 = new System.Windows.Forms.RichTextBox();
				this.richTextBox1 = new System.Windows.Forms.RichTextBox();
				this.button1 = new System.Windows.Forms.Button();
				this.rightpanel = new System.Windows.Forms.Panel();
				this.treeView2 = new System.Windows.Forms.TreeView();
				this.statusBar1 = new System.Windows.Forms.StatusBar();
				this.panel1 = new System.Windows.Forms.Panel();
				this.splitter1 = new System.Windows.Forms.Splitter();
				this.leftpanel.SuspendLayout();
				this.rightpanel.SuspendLayout();
				this.panel1.SuspendLayout();
				this.SuspendLayout();
				// 
				// leftpanel
				// 
				this.leftpanel.BackColor = System.Drawing.Color.Aqua;
				this.leftpanel.Controls.Add(this.label1);
				this.leftpanel.Controls.Add(this.richTextBox2);
				this.leftpanel.Controls.Add(this.richTextBox1);
				this.leftpanel.Controls.Add(this.button1);
				this.leftpanel.Dock = System.Windows.Forms.DockStyle.Fill;
				this.leftpanel.Location = new System.Drawing.Point(0, 0);
				this.leftpanel.Name = "leftpanel";
				this.leftpanel.Size = new System.Drawing.Size(488, 494);
				this.leftpanel.TabIndex = 0;
				// 
				// label1
				// 
				this.label1.BackColor = System.Drawing.Color.Aqua;
				this.label1.Location = new System.Drawing.Point(0, 0);
				this.label1.Name = "label1";
				this.label1.Size = new System.Drawing.Size(288, 24);
				this.label1.TabIndex = 8;
				this.label1.Text = "Support for: Microsoft: Windows";
				// 
				// richTextBox2
				// 
				this.richTextBox2.Location = new System.Drawing.Point(16, 32);
				this.richTextBox2.Name = "richTextBox2";
				this.richTextBox2.Size = new System.Drawing.Size(296, 240);
				this.richTextBox2.TabIndex = 7;
				this.richTextBox2.Text = "";
				// 
				// richTextBox1
				// 
				this.richTextBox1.Location = new System.Drawing.Point(8, 278);
				this.richTextBox1.Name = "richTextBox1";
				this.richTextBox1.Size = new System.Drawing.Size(232, 40);
				this.richTextBox1.TabIndex = 6;
				this.richTextBox1.Text = "";
				// 
				// button1
				// 
				this.button1.Location = new System.Drawing.Point(248, 280);
				this.button1.Name = "button1";
				this.button1.Size = new System.Drawing.Size(56, 40);
				this.button1.TabIndex = 5;
				this.button1.Text = "Send";
				// 
				// rightpanel
				// 
				this.rightpanel.BackColor = System.Drawing.Color.Beige;
				this.rightpanel.Controls.Add(this.treeView2);
				this.rightpanel.Dock = System.Windows.Forms.DockStyle.Right;
				this.rightpanel.Location = new System.Drawing.Point(488, 0);
				this.rightpanel.Name = "rightpanel";
				this.rightpanel.Size = new System.Drawing.Size(184, 494);
				this.rightpanel.TabIndex = 1;
				// 
				// treeView2
				// 
				this.treeView2.Dock = System.Windows.Forms.DockStyle.Fill;
				this.treeView2.ImageIndex = -1;
				this.treeView2.Location = new System.Drawing.Point(0, 0);
				this.treeView2.Name = "treeView2";
				this.treeView2.Nodes.AddRange(new System.Windows.Forms.TreeNode[] {
																					  new System.Windows.Forms.TreeNode("NodeA", new System.Windows.Forms.TreeNode[] {
																																										 new System.Windows.Forms.TreeNode("ChildA"),
																																										 new System.Windows.Forms.TreeNode("ChildB")}),
																					  new System.Windows.Forms.TreeNode("NodeB", new System.Windows.Forms.TreeNode[] {
																																										 new System.Windows.Forms.TreeNode("NodeC"),
																																										 new System.Windows.Forms.TreeNode("ChildB")}),
																					  new System.Windows.Forms.TreeNode("NodeC", new System.Windows.Forms.TreeNode[] {
																																										 new System.Windows.Forms.TreeNode("ChildC"),
																																										 new System.Windows.Forms.TreeNode("ChildX")}),
																					  new System.Windows.Forms.TreeNode("NodeE"),
																					  new System.Windows.Forms.TreeNode("NodeF"),
																					  new System.Windows.Forms.TreeNode("NodeG"),
																					  new System.Windows.Forms.TreeNode("NodeH")});
				this.treeView2.SelectedImageIndex = -1;
				this.treeView2.Size = new System.Drawing.Size(184, 494);
				this.treeView2.TabIndex = 0;
				// 
				// statusBar1
				// 
				this.statusBar1.Location = new System.Drawing.Point(8, 327);
				this.statusBar1.Name = "statusBar1";
				this.statusBar1.Size = new System.Drawing.Size(512, 22);
				this.statusBar1.TabIndex = 2;
				this.statusBar1.Text = "statusBar1";
				// 
				// panel1
				// 
				this.panel1.Controls.Add(this.splitter1);
				this.panel1.Controls.Add(this.leftpanel);
				this.panel1.Controls.Add(this.rightpanel);
				this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
				this.panel1.Location = new System.Drawing.Point(0, 0);
				this.panel1.Name = "panel1";
				this.panel1.Size = new System.Drawing.Size(672, 494);
				this.panel1.TabIndex = 2;
				// 
				// splitter1
				// 
				this.splitter1.Dock = System.Windows.Forms.DockStyle.Right;
				this.splitter1.Location = new System.Drawing.Point(485, 0);
				this.splitter1.Name = "splitter1";
				this.splitter1.Size = new System.Drawing.Size(3, 494);
				this.splitter1.TabIndex = 2;
				this.splitter1.TabStop = false;
				// 
				// MyForm
				// 
				this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
				this.ClientSize = new System.Drawing.Size(672, 494);
				this.Controls.Add(this.panel1);
				this.Name = "MyForm";
				this.Text = "MyForm";
				this.leftpanel.ResumeLayout(false);
				this.rightpanel.ResumeLayout(false);
				this.panel1.ResumeLayout(false);
				this.ResumeLayout(false);

			}
			#endregion
        
		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		[STAThread]
		static void Main() 
		{
			Application.Run(new MyForm());
		}
	}
 
Shelton,

Yes, that was it. thanks. I see now what i did wrong.
Thanks tons for your help.

dushkin
PS - i didn't realize that amt of code posted was taboo.
i'll keep that in mind. cheers.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top