怎样在C#中实现页面之间的转换

namuda 2005-03-23 02:18:54
在C#中怎么通过不同的Button的点击(或者工具栏中的Button)来实现类似与TabControl那样的在不同面版之间的转换,就是面版没有TabControl的头上的标题,不同的面版中含有不同的控件,各位能明白我的意思吗??也就是点击Button来实现页面之间的转换,谢谢帮助,在线等
...全文
171 20 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
20 条回复
切换为时间正序
请发表友善的回复…
发表回复
runi 2005-03-23
  • 打赏
  • 举报
回复
用panel
WTaoboy 2005-03-23
  • 打赏
  • 举报
回复
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace WindowsApplication3
{
/// <summary>
/// Form1 の概要の説明です。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
/// <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.panel1 = new System.Windows.Forms.Panel();
this.panel2 = new System.Windows.Forms.Panel();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.panel1.SuspendLayout();
this.panel2.SuspendLayout();
this.SuspendLayout();
//
// panel1
//
this.panel1.Controls.Add(this.label1);
this.panel1.Location = new System.Drawing.Point(16, 16);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(248, 168);
this.panel1.TabIndex = 0;
//
// panel2
//
this.panel2.Controls.Add(this.label2);
this.panel2.Location = new System.Drawing.Point(22, 52);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(248, 168);
this.panel2.TabIndex = 1;
this.panel2.Visible = false;
//
// label1
//
this.label1.Location = new System.Drawing.Point(40, 8);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(80, 16);
this.label1.TabIndex = 0;
this.label1.Text = "label1";
//
// label2
//
this.label2.Location = new System.Drawing.Point(96, 104);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(104, 32);
this.label2.TabIndex = 0;
this.label2.Text = "label2";
//
// button1
//
this.button1.Location = new System.Drawing.Point(40, 240);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(80, 16);
this.button1.TabIndex = 2;
this.button1.Text = "button1";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.Location = new System.Drawing.Point(176, 232);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(88, 24);
this.button2.TabIndex = 3;
this.button2.Text = "button2";
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 12);
this.ClientSize = new System.Drawing.Size(292, 273);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.panel2);
this.Controls.Add(this.panel1);
this.Name = "Form1";
this.Text = "Form1";
this.panel1.ResumeLayout(false);
this.panel2.ResumeLayout(false);
this.ResumeLayout(false);

}
#endregion

/// <summary>
/// アプリケーションのメイン エントリ ポイントです。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}

private void button2_Click(object sender, System.EventArgs e)
{
this.panel2.Visible=false;
this.panel1.Visible=true;

}

private void button1_Click(object sender, System.EventArgs e)
{
this.panel1.Visible=false;
this.panel2.Visible=true;

}
}
}
dangerousdon 2005-03-23
  • 打赏
  • 举报
回复
panel比较好用!
s2722357 2005-03-23
  • 打赏
  • 举报
回复
把控件放到Panel里面
将两个Panel叠加起
然后根据点击的按钮来判断不同panel的显示和隐藏
=================================================
这种就可以呀 ~
s2722357 2005-03-23
  • 打赏
  • 举报
回复
tabControl.SelectedTab=tabArticle

你看看是这种咚咚吗 ~?


nga96 2005-03-23
  • 打赏
  • 举报
回复
UP
WTaoboy 2005-03-23
  • 打赏
  • 举报
回复
把控件放到Panel里面
将两个Panel叠加起
然后根据点击的按钮来判断不同panel的显示和隐藏
namuda 2005-03-23
  • 打赏
  • 举报
回复
还有,这些pannel要重叠起来,也就是在一个时间内最多只能显示一个pannel,可以吗??怎么实现??
能具体的代码给点吗??谢谢??等ing !!!
zr1982930 2005-03-23
  • 打赏
  • 举报
回复
有道理,用Pannel。
namuda 2005-03-23
  • 打赏
  • 举报
回复
???谁能给点具体的代码吗?/谢谢
namuda 2005-03-23
  • 打赏
  • 举报
回复
那让pannel1显示而pannel2不显示怎么实现啊
就是pannel1.Show();
ycy589 2005-03-23
  • 打赏
  • 举报
回复
js需客户端代码

panel需服务器端代码

两者都行,看项目要求了

kgdiwss 2005-03-23
  • 打赏
  • 举报
回复
把控件放到Panel里面
然后根据点击的按钮来判断不同panel的显示和隐藏


就是这样了,哈哈。
namuda 2005-03-23
  • 打赏
  • 举报
回复
但是好象把控件放在panel2,panel1上也有该控件啊,为什么啊
godson_h 2005-03-23
  • 打赏
  • 举报
回复
是做成向导那样的效果吧,用panel吧
ffflyyy_470 2005-03-23
  • 打赏
  • 举报
回复
用panel包装控件,button控制显示哪个panel
ffflyyy_470 2005-03-23
  • 打赏
  • 举报
回复
用panel包装控件,button控制显示哪个panel
  • 打赏
  • 举报
回复
用Div吧,配合JavaScript控制可见性就好了。
Grace_ghb 2005-03-23
  • 打赏
  • 举报
回复
不同的面版做成不同的用户控件吧,控制这些用户控件显示与否?
goldentimecym 2005-03-23
  • 打赏
  • 举报
回复
把控件放到Panel里面
然后根据点击的按钮来判断不同panel的显示和隐藏

111,098

社区成员

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

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

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