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);
}
}
}
C# 基本控件使用练习的更多相关文章
- JS调用Android、Ios原生控件
在上一篇博客中已经和大家聊了,关于JS与Android.Ios原生控件之间相互通信的详细代码实现,今天我们一起聊一下JS调用Android.Ios通信的相同点和不同点,以便帮助我们在进行混合式开发时, ...
- HTML5 progress和meter控件
在HTML5中,新增了progress和meter控件.progress控件为进度条控件,可表示任务的进度,如Windows系统中软件的安装.文件的复制等场景的进度.meter控件为计量条控件,表示某 ...
- 百度 flash html5自切换 多文件异步上传控件webuploader基本用法
双核浏览器下在chrome内核中使用uploadify总有302问题,也不知道如何修复,之所以喜欢360浏览器是因为帮客户控制渲染内核: 若页面需默认用极速核,增加标签:<meta name=& ...
- JS与APP原生控件交互
"热更新"."热部署"相信对于混合式开发的童鞋一定不陌生,那么APP怎么避免每次升级都要在APP应用商店发布呢?这里就用到了混合式开发的概念,对于电商网站尤其显 ...
- UWP开发必备:常用数据列表控件汇总比较
今天是想通过实例将UWP开发常用的数据列表做汇总比较,作为以后项目开发参考.UWP开发必备知识点总结请参照[UWP开发必备以及常用知识点总结]. 本次主要讨论以下控件: GridView:用于显示数据 ...
- 【踩坑速记】开源日历控件,顺便全面解析开源库打包发布到Bintray/Jcenter全过程(新),让开源更简单~
一.写在前面 自使用android studio开始,就被它独特的依赖方式:compile 'com.android.support:appcompat-v7:25.0.1'所深深吸引,自从有了它,麻 ...
- 对百度WebUploader开源上传控件的二次封装,精简前端代码(两句代码搞定上传)
前言 首先声明一下,我这个是对WebUploader开源上传控件的二次封装,底层还是WebUploader实现的,只是为了更简洁的使用他而已. 下面先介绍一下WebUploader 简介: WebUp ...
- Windows API 设置窗口下控件Enable属性
参考页面: http://www.yuanjiaocheng.net/webapi/create-crud-api-1-put.html http://www.yuanjiaocheng.net/we ...
- VB.NET设置控件和窗体的显示级别
前言:在用VB.NET开发射频检测系统ADS时,当激活已存在的目标MDI子窗体时,被其他子窗体遮住了,导致目标MDI子窗体不能显示. 这个问题怎么解决呢?网上看到一篇帖子VB.NET设置控件和窗体的显 ...
- Win10 UWP开发系列——开源控件库:UWPCommunityToolkit
在开发应用的过程中,不可避免的会使用第三方类库.之前用过一个WinRTXamlToolkit.UWP,现在微软官方发布了一个新的开源控件库—— UWPCommunityToolkit 项目代码托管在G ...
随机推荐
- LuoguP7222 [RC-04] 信息学竞赛 题解
Content 给定一个角 \(\alpha\),求 \(\beta=90^\circ-\alpha\). 数据范围:\(\alpha\in[-2^{31},2^{31}-1]\). Solution ...
- WPF DataGrid OxyPlot 卡顿优化
不是优化,我是想用这个标题吸引遇到相同问题的同学过来看看. UI如下,左边DataGrid有7列,右边OxyPlot显示折线图 列表4000+数据,折线图4000+个点,页面卡的用不了. 体现就是列表 ...
- 页面图片懒加载、延迟加载(lazyload)
文档:http://www.h-ui.net/lib/jQuery.lazyload.js.shtml github地址:https://github.com/jieyou/lazyload Lazy ...
- FastAPI(六十五)实战开发《在线课程学习系统》基础架构的搭建
在之前三篇,我们分享的就是需求的分析,基本接口的整理,数据库链接的配置.这次我们分享项目的基本框架,目录结构如下: common目录 通用的目录,一些通用的处理放在这里 models目录 数据库相关的 ...
- .NET 多条件动态参数查询方法 - SqlSugar ORM
1.简单多条件多动参数 创建数据库对象 //创建数据库对象 SqlSugarClient SqlSugarClient db = new SqlSugarClient(new ConnectionCo ...
- 【LeetCode】157. Read N Characters Given Read4 解题报告(C++)
作者: 负雪明烛 id: fuxuemingzhu 个人博客:http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 直接调用 日期 题目地址:https://leetco ...
- InnoDB 聚集索引和非聚集索引、覆盖索引、回表、索引下推简述
关于InnoDB 存储引擎的有聚集索引和非聚集索引,覆盖索引,回表,索引下推等概念,这些知识点比较多,也比较零碎,但是概念都是基于索引建立的,本文从索引查找数据讲述上述概念. 聚集索引和非聚集索引 在 ...
- Codeforces 855B:Marvolo Gaunt's Ring(枚举,前后缀)
B. Marvolo Gaunt's Ring Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaun ...
- Redis 的 3 种集群方案对比
数据持久化 主从复制 自动故障恢复 集群化 数据持久化本质上是为了做数据备份,有了数据持久化,当Redis宕机时,我们可以把数据从磁盘上恢复回来,但在数据恢复之前,服务是不可用的,而且数据恢复的时间取 ...
- [Box] Robust Training and Initialization of Deep Neural Networks: An Adaptive Basis Viewpoint
目录 概 主要内容 LSGD Box 初始化 Box for Resnet 代码 Cyr E C, Gulian M, Patel R G, et al. Robust Training and In ...