首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

C#第11周实验-任务3-设计一个窗体,窗体下有两个文本框,一个按钮,2个单选按钮-实现单击按钮后,根据单选按钮,将对应文本框中内容显示在标签

2012-11-25 
C#--第11周实验--任务3--设计一个窗体,窗体上有两个文本框,一个按钮,2个单选按钮--实现单击按钮后,根据单

C#--第11周实验--任务3--设计一个窗体,窗体上有两个文本框,一个按钮,2个单选按钮--实现单击按钮后,根据单选按钮,将对应文本框中内容显示在标签。


/* (程序头部注释开始)   * 程序的版权和版本声明部分   * Copyright (c) 2011, 烟台大学计算机学院学生    * All rights reserved.   * 文件名称:设计一个窗体  * 作 者: 雷恒鑫    * 完成日期: 2012 年 11 月 10 日   * 版 本 号: V1.0    * 对任务及求解方法的描述部分   * 输入描述:窗体上有两个文本框:一个文本框中最多输入字符6个; * 输入描述:一个文本框中输入任何内容都显示*号。 * 输入描述:再添加一个按钮、2个单选按钮。实现单击按钮后。 * 输入描述:根据单选按钮,将对应文本框中内容显示在标签。 * 问题描述:   * 程序输出:   * 程序头部的注释结束   */using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;namespace WindowsFormsApplication_twelve{    public partial class Form1 : Form    {        Boolean b = true;        public Form1()        {            InitializeComponent();            this.StartPosition = FormStartPosition.CenterScreen;            //this.FormBorderStyle = FormBorderStyle.FixedSingle;        }        private void label1_Click(object sender, EventArgs e)        {        }        private void button1_Click(object sender, EventArgs e)        {            // label1.Text = DateTime.Now.ToString();            if (b == false)            {                textBox1.SelectAll();                label1.Text = textBox1.SelectedText;            }            else            {                textBox2.SelectAll();                label1.Text = textBox2.SelectedText;            }        }        private void Form1_Load(object sender, EventArgs e)        {            this.Text = "文本框实例";            /*button1.Text = "单击该按钮显示系统当前时间";            this.MaximizeBox = false;            this.MinimizeBox = false;*/            this.StartPosition = FormStartPosition.CenterScreen;            //button1.Text = "复制选择文本至标签";        }        private void textBox1_KeyPress(object sender, KeyPressEventArgs e)        {            textBox1.MaxLength = 6;        }        private void textBox2_TextChanged(object sender, EventArgs e)        {        }        private void textBox1_TextChanged(object sender, EventArgs e)        {        }        private void textBox2_KeyPress(object sender, KeyPressEventArgs e)        {            textBox2.PasswordChar = '*';        }        private void radioButton1_CheckedChanged(object sender, EventArgs e)        {            b = false;        }        private void radioButton2_CheckedChanged(object sender, EventArgs e)        {            b = true;        }    }}


 

运行结果;

C#第11周实验-任务3-设计一个窗体,窗体下有两个文本框,一个按钮,2个单选按钮-实现单击按钮后,根据单选按钮,将对应文本框中内容显示在标签

C#第11周实验-任务3-设计一个窗体,窗体下有两个文本框,一个按钮,2个单选按钮-实现单击按钮后,根据单选按钮,将对应文本框中内容显示在标签

 

热点排行