隐藏页面特效

C# 基本控件使用练习

自己设计并编写一个 Windows 应用程序,要求用到 TextBox、GroupBox、RadioButton、CheckBox、ComboBox、ListBox 控件。

 

 

 

 

代码如下:

页面1:

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; //页面1 namespace Testing3_2 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { string name = textName.Text; string sex; if (radioMan.Checked == true) { sex = radioMan.Text; } else { sex = radioWoman.Text; } string age = textAge.Text; string strclass = comboBox1.Text; string strhobby=""; if (checkBox1.Checked == true) { strhobby = strhobby + checkBox1.Text+" "; } if (checkBox2.Checked == true) { strhobby = strhobby+checkBox2.Text + " "; } if (checkBox3.Checked == true) { strhobby = strhobby + checkBox3.Text + " "; } if (checkBox4.Checked == true) { strhobby = strhobby + checkBox4.Text + " "; } string text = listBox2.Text; Form2 frm = new Form2();//实例化form2 Form2.frms.setLabel(name,sex,age, strclass, strhobby, text); this.Hide();//隐藏现在这个窗口 frm.Show();//打开新窗体 } private void groupBox1_Enter(object sender, EventArgs e) { } private void buttonin_Click(object sender, EventArgs e) { int i; for (i = 0; i < listBox1.SelectedItems.Count; i++) { string str1 = listBox1.SelectedItems[i] + ""; if (!(listBox2.Items.Contains(str1))) { listBox2.Items.Add(str1); } listBox1.Items.Remove(str1); } } private void buttonout_Click(object sender, EventArgs e) { int i; for (i = 0; i < listBox2.SelectedItems.Count; i++) { string str1 = listBox2.SelectedItems[i] + ""; if (!(listBox1.Items.Contains(str1))) { listBox1.Items.Add(str1); } listBox2.Items.Remove(str1); } } private void textAge_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar != 8 && !Char.IsDigit(e.KeyChar)) { e.Handled = true; } } } }

 

页面2:

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace Testing3_2 { public partial class Form2 : Form { public static Form2 frms = null; public Form2() { InitializeComponent(); frms = this; } public void setLabel(string name,string sex,string age,string strclass,string strhobby,string text) { label1.Text = name; label2.Text = sex; label3.Text = age; label4.Text = strclass; label6.Text = strhobby; label5.Text = text; } private void button1_Click(object sender, EventArgs e) { //this.Close(); System.Environment.Exit(0); } } }

 


__EOF__

本文作者往心。
本文链接https://www.cnblogs.com/lx06/p/15686213.html
关于博主:评论和私信会在第一时间回复。或者直接私信我。
版权声明:本博客转载请注明出处!
声援博主:如果您觉得文章对您有帮助,可以点击文章右下角推荐一下。您的鼓励是博主的最大动力!
posted @   往心。  阅读(145)  评论(0编辑  收藏  举报
编辑推荐:
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· AI与.NET技术实操系列(六):基于图像分类模型对图像进行分类
历史上的今天:
2020-12-14 jsp标签问题
点击右上角即可分享
微信分享提示