自己设计并编写一个 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);
}
}
}

C# 基本控件使用练习的更多相关文章

  1. JS调用Android、Ios原生控件

    在上一篇博客中已经和大家聊了,关于JS与Android.Ios原生控件之间相互通信的详细代码实现,今天我们一起聊一下JS调用Android.Ios通信的相同点和不同点,以便帮助我们在进行混合式开发时, ...

  2. HTML5 progress和meter控件

    在HTML5中,新增了progress和meter控件.progress控件为进度条控件,可表示任务的进度,如Windows系统中软件的安装.文件的复制等场景的进度.meter控件为计量条控件,表示某 ...

  3. 百度 flash html5自切换 多文件异步上传控件webuploader基本用法

    双核浏览器下在chrome内核中使用uploadify总有302问题,也不知道如何修复,之所以喜欢360浏览器是因为帮客户控制渲染内核: 若页面需默认用极速核,增加标签:<meta name=& ...

  4. JS与APP原生控件交互

    "热更新"."热部署"相信对于混合式开发的童鞋一定不陌生,那么APP怎么避免每次升级都要在APP应用商店发布呢?这里就用到了混合式开发的概念,对于电商网站尤其显 ...

  5. UWP开发必备:常用数据列表控件汇总比较

    今天是想通过实例将UWP开发常用的数据列表做汇总比较,作为以后项目开发参考.UWP开发必备知识点总结请参照[UWP开发必备以及常用知识点总结]. 本次主要讨论以下控件: GridView:用于显示数据 ...

  6. 【踩坑速记】开源日历控件,顺便全面解析开源库打包发布到Bintray/Jcenter全过程(新),让开源更简单~

    一.写在前面 自使用android studio开始,就被它独特的依赖方式:compile 'com.android.support:appcompat-v7:25.0.1'所深深吸引,自从有了它,麻 ...

  7. 对百度WebUploader开源上传控件的二次封装,精简前端代码(两句代码搞定上传)

    前言 首先声明一下,我这个是对WebUploader开源上传控件的二次封装,底层还是WebUploader实现的,只是为了更简洁的使用他而已. 下面先介绍一下WebUploader 简介: WebUp ...

  8. Windows API 设置窗口下控件Enable属性

    参考页面: http://www.yuanjiaocheng.net/webapi/create-crud-api-1-put.html http://www.yuanjiaocheng.net/we ...

  9. VB.NET设置控件和窗体的显示级别

    前言:在用VB.NET开发射频检测系统ADS时,当激活已存在的目标MDI子窗体时,被其他子窗体遮住了,导致目标MDI子窗体不能显示. 这个问题怎么解决呢?网上看到一篇帖子VB.NET设置控件和窗体的显 ...

  10. Win10 UWP开发系列——开源控件库:UWPCommunityToolkit

    在开发应用的过程中,不可避免的会使用第三方类库.之前用过一个WinRTXamlToolkit.UWP,现在微软官方发布了一个新的开源控件库—— UWPCommunityToolkit 项目代码托管在G ...

随机推荐

  1. Python3 中bytes数据类型深入理解(ASCII码对照表)

    bytes的来源 bytes 是 Python 3.x 新增的类型,在 Python 2.x 中是不存在的. bytes 的意思是"字节",以字节为单位存储数据.而一个字节二进制为 ...

  2. 7.2 Tornado异步

    7.2 Tornado异步 因为epoll主要是用来解决网络IO的并发问题,所以Tornado的异步编程也主要体现在网络IO的异步上,即异步Web请求. 1. tornado.httpclient.A ...

  3. ACwing2.01背包问题

    题目: 有 N 件物品和一个容量是 V 的背包.每件物品只能使用一次. 第 i 件物品的体积是 vi,价值是 wi. 求解将哪些物品装入背包,可使这些物品的总体积不超过背包容量,且总价值最大. 输出最 ...

  4. 🍃【Spring专题】「原理系列」SpringMVC的运行工作原理(补充修订)

    承接相关之前的SpringMVC的框架技术的流程分析 初始化流程(initStrategies) 执行流程 寻找相关HandlerMapping 请求到DispatcherServlet类进行执行相关 ...

  5. ByteBuddy代码生成技术

    简介 如官网所说Byte Buddy 是一个代码生成和操作库,用于在Java应用程序运行时创建和修改Java类,而无需编译器的帮助.除了Java类库附带的代码生成实用程序外,Byte Buddy还允许 ...

  6. UE4之第一个飞机游戏

    开始之前 UE4官网 初识ue4教程(1~9节): https://www.bilibili.com/video/BV164411Y732?p=1 第一个飞机游戏: http://www.sikied ...

  7. 【LeetCode】1099. Two Sum Less Than K 解题报告(C++)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客:http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 暴力求解 日期 题目地址:https://leetco ...

  8. 【LeetCode】771. Jewels and Stones 解题报告

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述: 题目大意 解题方法 数组count 字典Counter 日期 题目地址 ...

  9. D. Puzzles(Codeforces Round #362 (Div. 2))

    D. Puzzles Barney lives in country USC (United States of Charzeh). USC has n cities numbered from 1 ...

  10. 基于Spring MVC + Spring + MyBatis的【人事管理系统】

    资源下载:https://download.csdn.net/download/weixin_44893902/33163160 一.语言和环境 实现语言:JAVA语言 环境要求:IDEA/Eclip ...