文本框的走马灯效果
2016-05-03 15:41
363 查看
界面设计:
![](https://images2015.cnblogs.com/blog/841297/201605/841297-20160503153636591-2030013753.png)
拖动timer控件进来
![](https://images2015.cnblogs.com/blog/841297/201605/841297-20160503153749826-591172394.png)
设置拖进来的timer控件的Tick事件
![](https://images2015.cnblogs.com/blog/841297/201605/841297-20160503153907982-253756992.png)
具体代码如下:
![](https://images2015.cnblogs.com/blog/841297/201605/841297-20160503153636591-2030013753.png)
拖动timer控件进来
![](https://images2015.cnblogs.com/blog/841297/201605/841297-20160503153749826-591172394.png)
设置拖进来的timer控件的Tick事件
![](https://images2015.cnblogs.com/blog/841297/201605/841297-20160503153907982-253756992.png)
具体代码如下:
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 走马灯 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } //定义一个全局变量,用于指示走马灯的方向 string flag = ""; //此处为每隔指定时间时间控件激发的事件 private void timer1_Tick(object sender, EventArgs e) { //运行自定义的run方法 run(); } //向左滚动按钮 private void button1_Click(object sender, EventArgs e) { //指示走马灯方向 flag = "left"; //时间控件启用 timer1.Enabled = true; } private void button2_Click(object sender, EventArgs e) { //指示走马灯方向 flag = "right"; //时间控件启用 timer1.Enabled = true; } //自定义的run方法 public void run() { //如果指示方向是左 if (flag == "left") { //字符串的截取拼接 textBox1.Text = textBox1.Text.Substring(1, (textBox1.Text.Length - 1)) + textBox1.Text.Substring(0, 1); } //如果指示方向是右 else if (flag == "right") { //字符串的截取拼接 textBox1.Text = textBox1.Text.Substring(textBox1.Text.Length - 1, 1) + textBox1.Text.Substring(0,textBox1.Text.Length-1); } } } }
相关文章推荐
- 通过js把html标签转化为普通字符,再用java进行反转
- iconic 安装和使用
- Launcher启动过程详解
- [打造自己的代码库]ExcelUtil:(POI)解析Excel Sheet 与 String[][][]互转
- c# http请求执行超时,解决办法(给某个方法设定超时时间)
- 【BFS/DBFS】Open the Lock【双向广搜】
- 自定义 UITableViewRowAction
- 利用tp框架做前后台分离
- android退出activity
- 山东省第一届ACM大学生程序设计竞赛 Fairy tale 大模拟
- UIPageViewControllerDelegate
- 【VS开发】CListCtrl控件使用
- sql Server 2008一行转多行的问题
- 10个顶级Web移动开发JavaScript框架
- JAVA线程的创建与启动线程
- windows系统创建软连接实例
- iOS 不规则的UIImageView 实现
- 安卓下Camera技术总结----(个人理解)
- Qrcode生成二维码支持中文,带图片,带文字
- linux 系统服务