怪事,Splitter 没有效果

蝈蝈俊 2003-09-21 03:51:42
怪事,Splitter 没有效果,代码看下面:

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

namespace SiteDown
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.StatusBar statusBar1;
private System.Windows.Forms.MainMenu mainMenu1;
private System.Windows.Forms.MenuItem menuItem1;
private System.Windows.Forms.MenuItem menuItem2;
private System.Windows.Forms.MenuItem menuItem3;
private System.Windows.Forms.MenuItem menuItem4;
private System.Windows.Forms.MenuItem menuItem5;
private System.Windows.Forms.MenuItem menuItem6;
private System.Windows.Forms.MenuItem menuItem7;
private System.Windows.Forms.ToolBar toolBar1;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.Splitter splitter1;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;

public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();

//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}

/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.statusBar1 = new System.Windows.Forms.StatusBar();
this.mainMenu1 = new System.Windows.Forms.MainMenu();
this.menuItem1 = new System.Windows.Forms.MenuItem();
this.menuItem2 = new System.Windows.Forms.MenuItem();
this.menuItem3 = new System.Windows.Forms.MenuItem();
this.menuItem4 = new System.Windows.Forms.MenuItem();
this.menuItem5 = new System.Windows.Forms.MenuItem();
this.menuItem6 = new System.Windows.Forms.MenuItem();
this.menuItem7 = new System.Windows.Forms.MenuItem();
this.toolBar1 = new System.Windows.Forms.ToolBar();
this.panel1 = new System.Windows.Forms.Panel();
this.panel2 = new System.Windows.Forms.Panel();
this.splitter1 = new System.Windows.Forms.Splitter();
this.panel2.SuspendLayout();
this.SuspendLayout();
//
// statusBar1
//
this.statusBar1.Location = new System.Drawing.Point(0, 251);
this.statusBar1.Name = "statusBar1";
this.statusBar1.Size = new System.Drawing.Size(448, 22);
this.statusBar1.TabIndex = 2;
this.statusBar1.Text = "statusBar1";
//
// mainMenu1
//
this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem1,
this.menuItem3,
this.menuItem6});
//
// menuItem1
//
this.menuItem1.Index = 0;
this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem2});
this.menuItem1.Text = "文件";
//
// menuItem2
//
this.menuItem2.Index = 0;
this.menuItem2.Text = "退出";
//
// menuItem3
//
this.menuItem3.Index = 1;
this.menuItem3.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem4,
this.menuItem5});
this.menuItem3.Text = "操作";
//
// menuItem4
//
this.menuItem4.Index = 0;
this.menuItem4.Text = "增加节点";
//
// menuItem5
//
this.menuItem5.Index = 1;
this.menuItem5.Text = "删除节点";
//
// menuItem6
//
this.menuItem6.Index = 2;
this.menuItem6.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem7});
this.menuItem6.Text = "帮助";
//
// menuItem7
//
this.menuItem7.Index = 0;
this.menuItem7.Text = "关于";
//
// toolBar1
//
this.toolBar1.DropDownArrows = true;
this.toolBar1.Location = new System.Drawing.Point(0, 0);
this.toolBar1.Name = "toolBar1";
this.toolBar1.ShowToolTips = true;
this.toolBar1.Size = new System.Drawing.Size(448, 42);
this.toolBar1.TabIndex = 5;
//
// panel1
//
this.panel1.Dock = System.Windows.Forms.DockStyle.Left;
this.panel1.Location = new System.Drawing.Point(0, 42);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(120, 209);
this.panel1.TabIndex = 6;
this.panel1.Resize += new System.EventHandler(this.panel2_Resize);
this.panel1.Paint += new System.Windows.Forms.PaintEventHandler(this.panel2_Paint);
//
// panel2
//
this.panel2.Controls.Add(this.splitter1);
this.panel2.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel2.Location = new System.Drawing.Point(120, 42);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(328, 209);
this.panel2.TabIndex = 7;
this.panel2.Resize += new System.EventHandler(this.panel2_Resize);
this.panel2.Paint += new System.Windows.Forms.PaintEventHandler(this.panel2_Paint);
//
// splitter1
//
this.splitter1.BackColor = System.Drawing.SystemColors.Desktop;
this.splitter1.Location = new System.Drawing.Point(0, 0);
this.splitter1.Name = "splitter1";
this.splitter1.Size = new System.Drawing.Size(3, 209);
this.splitter1.TabIndex = 0;
this.splitter1.TabStop = false;
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(448, 273);
this.Controls.Add(this.panel2);
this.Controls.Add(this.panel1);
this.Controls.Add(this.toolBar1);
this.Controls.Add(this.statusBar1);
this.Menu = this.mainMenu1;
this.Name = "Form1";
this.Text = "站点下载工具 2003年9月21日";
this.Load += new System.EventHandler(this.Form1_Load);
this.panel2.ResumeLayout(false);
this.ResumeLayout(false);

}
#endregion

/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}

private void Form1_Load(object sender, System.EventArgs e)
{

}

private void panel2_Resize(object sender, System.EventArgs e)
{
((Panel)sender).Invalidate();
}

private void panel2_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
Panel panel = (Panel)sender;
Graphics grfx = e.Graphics;
grfx.DrawEllipse(Pens.Black,0,0,panel.Width-1,panel.Height-1);
}
}
}
...全文
213 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
carper 2003-09-21
  • 打赏
  • 举报
回复
http://www.csdn.net/Develop/read_article.asp?id=21176
carper 2003-09-21
  • 打赏
  • 举报
回复
怪事。创建顺序里面为

panel1
panel2
splitter1
(顺序看InitializeComponent 函数内的代码)
就是上面的代码,就有上面的问题。


如果你改成
panel1
splitter1
panel2

这样就没问题了。

注意这三个控件进入 win Form 的先后次序,如果不是这样的先后次序,就会出错,不知道算不算是一个 bug

wirte 2003-09-21
  • 打赏
  • 举报
回复
帮你顶一下。

111,125

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧