自己设计并编写一个 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. CF1437A Marketing Scheme 题解

    Content 有 \(t\) 组询问,每组询问给定两个整数 \(l,r\),问是否存在一个 \(a\),使得 \(\forall x\in[l,r]\),都有 \(x\mod a\geqslant\ ...

  2. LuoguP7072 [CSP-J2020] 直播获奖 题解

    Update \(\texttt{2020.11.13}\) 修改了一个小细节. \(\texttt{2020.11.16}\) 修改了一个错误. Content 有一场 \(n\) 个人的比赛,计划 ...

  3. linux服务器加入AD域(sssd)~ 通过域用户ssh登录加域的linux服务器

    搭建域控:参考 https://www.cnblogs.com/taosiyu/p/12009120.html 域控计算机全名: WIN-3PLKM2PLE6E.zhihu.test.com 域:zh ...

  4. 【LeetCode】515. Find Largest Value in Each Tree Row 解题报告(Python & C++ & Java)

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

  5. 【LeetCode】20. Valid Parentheses 有效的括号

    作者: 负雪明烛 id: fuxuemingzhu 个人博客:http://fuxuemingzhu.cn/ 个人公众号:负雪明烛 本文关键词:有效,括号,括号匹配,栈,题解,leetcode, 力扣 ...

  6. 【LeetCode】572. 另一个树的子树 Subtree of Another Tree(Python & Java)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 方法一:先序遍历 方法二:DFS + DFS 方法三 ...

  7. 【LeetCode】47. Permutations II 解题报告(Python & C++)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 方法一:递归 方法二:回溯法 日期 题目地址:htt ...

  8. Codeforces 888D: Almost Identity Permutations(错排公式,组合数)

    A permutation \(p\) of size \(n\) is an array such that every integer from \(1\) to \(n\) occurs exa ...

  9. [opencv]KAZE、AKAZE特征检测、匹配与对象查找

    AkAZE是KAZE的加速版 与SIFT,SUFR比较: 1.更加稳定 2.非线性尺度空间 3.AKAZE速度更加快 4.比较新的算法,只有Opencv新的版本才可以用 AKAZE局部匹配介绍 1.A ...

  10. 基于Spring MVC + Spring + MyBatis的【学生信息管理系统】

    资源下载:https://download.csdn.net/download/weixin_44893902/45603211 练习点设计: 模糊查询.删除.新增 一.语言和环境 实现语言:JAVA ...