上一步,下一步
c#如何实现以下功能:
form1上有textbox控件,下一步按钮,点击下一步后打开form2,form1关闭,
form2有上一步按钮,点击后回到form1,显示为textbox输入值后的form1。
不知道问题是否已经清楚,小弟是新手,望各位高手说的详细,不胜感激!
[解决办法]
用一个form就可以了,用不同的panle 控制界面的显隐
[解决办法]
楼主是想做向导控件吧。向导控件不是这个样子的。不是多个窗体这么玩儿的。
其中一种简单的实现方式是使用 TabControl,然后隐藏其 Header。
标准的实现方式是自定义一个 WizardPage 控件,一个 WizardControl,WizardControl 包含多个 WizardPage,“上一步”、“下一步” 这样的按钮是在 WizardControl 中的,而不是在每一个 Page 中。
参考:
A .NET Wizard control
Windows 2000 Style Wizards
Aero Wizard in VB.NET
[解决办法]
Form.Text 控制窗体标题
[解决办法]
我写一个很简单的给你看,其他的你根据情况来改吧
- C# code
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;namespace WindowsFormsApplication1{ public partial class Form1 : Form { public Form1() { InitializeComponent(); } //点击上一步的时候 private void button2_Click(object sender, EventArgs e) { show(); } //窗体加载的时候(默认为第一个页面,即上一步的页面,注意这里是只有两个页面,多个时请根据情况来) private void Form1_Load(object sender, EventArgs e) { show(); } public void show() { //设置窗体名称 Form1 form = new Form1(); form.Text = "上一步页面"; //上一步的页面显现 this.panel1.Visible = true; //下一步的页面隐藏 this.panel2.Visible = false; } //点击下一步的时候 private void button1_Click(object sender, EventArgs e) { this.panel2.Visible = true; this.panel1.Visible = false; //设置窗体名称 Form1 form = new Form1(); form.Text = "下一步页面"; } }}