C# winform学习 Timer、Textbox、Button
来源:互联网 发布:杭州贰贰网络怎么样 编辑:程序博客网 时间:2024/05/18 13:10
MessageBox(): 文本框
this.close()// 代表当前窗体结束
Button
public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { MessageBox.Show ("真听话"); this.Close(); } private void button2_Click(object sender, EventArgs e) { MessageBox.Show("不学习不是好孩子"); this.Close(); } // 给按钮一个新的坐标 private void button2_MouseEnter(object sender, EventArgs e) { // 给按钮一个随机坐标 int x = this.ClientSize.Width - button2.Width; int y = this.ClientSize.Height - button2.Height; Random r = new Random(); button1.Location = new Point(r.Next(0, x + 1), r.Next(0, y + 1)); } }
Textbox
wordWrap:指示文本框是否自动换行
ScrolBars :是否显示滚动条
PasswordChar: 以密码的形式输入(单一字符)
label:用来显示文本
TextChanged:文本框发生变化时触发事件
lblText.Text=txtwords.Text;(拿到了txtwords中的内容)
组件:timer
在指定的时间间隔内做一件指定的事情。
Timer---->Tick: 每隔一定时间发生的事件
timer:指定事件发生的频率
datetime.Now,tostring(); // 获取当前的时间,转换成string
Load属性:窗体加载的时候发生的事件;双击窗体,出现load属性
闪烁字:
private void timer1_Tick_1(object sender, EventArgs e) { string str=textBox1.Text ; //选取第2个(下标为1的)之后的字符+第1个字符起选1个字符 textBox1.Text = str.Substring(1) + str.Substring(0, 1); }闹钟:
private void timer2_Tick(object sender, EventArgs e) { label1.Text = DateTime.Now.ToString(); // 获得当前时间 if(DateTime .Now .Hour ==21&&DateTime .Now .Minute ==44&&DateTime .Now .Second ==32){ //到了设定的时间,闹钟响 SoundPlayer sound = new SoundPlayer(); // 命名空间为 using System.Media; sound.SoundLocation = @"F:\C#\video\1.wav"; // 找到文件的地址 sound.Stop(); } }
private void Form1_Load(object sender, EventArgs e) { label1.Text = DateTime.Now.ToString(); // 当前的时间以字符串的形式放在label中显示出来 }
阅读全文
0 0
- C# winform学习 Timer、Textbox、Button
- C#之WinForm基础 使用timer空间每500毫秒,textbox增加一个字
- C# WinForm开发系列 - TextBox
- C# WINFORM TEXTBOX水印效果
- C# winform textbox 水印效果
- C# winform TextBox常用小技巧
- C#设置WinForm快捷键(TextBox格式化,Perfect)
- C# winform button动态加载背景图
- [WinForm]C# Listview中添加Button
- C#中的Form,textBox,Bitmap,PictureBox,Button,WebBrowser
- C#的winform中控制TextBox中只能输入数字?
- c#中WinForm的TextBox循环自动滚动示例
- c#中WinForm的TextBox循环自动滚动示例
- (转)c#中WinForm的TextBox循环自动滚动
- c#中WinForm的TextBox循环自动滚动示例
- C# Winform 处理TextBox输入数字的几种方法
- C# winform中,动态绑定textbox,combox,datagridview的示例
- C#在WinForm中怎样让多行TEXTBOX的换行
- 漫谈透明状态栏和沉浸式状态栏
- 模拟滑动解锁界面
- 机器学习资料
- 【软考总结】设计模式之创建型
- Java数据库连接实例(JDBC)
- C# winform学习 Timer、Textbox、Button
- 异步图片GCD下载
- 说说JSON和JSONP,也许你会豁然开朗,含jQuery用例
- 35岁程序员的独家面试经历
- R语言初学
- 数组
- C++并发编程实战chapter1你好,C++的并发世界--笔记1--任务并行和数据并行
- SOAP协议和基于SOAP的开发流程详述(转载)
- 阿里物联网套件-服务端SDK学习实践(基础篇-7批量申请设备)