| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 696 人关注过本帖
标题:如何让光标随着文字往后移???
只看楼主 加入收藏
冲冲走过
Rank: 2
等 级:论坛游民
帖 子:69
专家分:72
注 册:2011-10-2
结帖率:91.67%
收藏
已结贴  问题点数:10 回复次数:1 
如何让光标随着文字往后移???
namespace 文字
{
  public partial class Form1 : Form
  {
  public Form1()
  {
  InitializeComponent();
  }
  string s = "苟利国家生死以,"+"\r\n"+"岂因祸福避趋之。"; int i = 0;
  private void timer1_Tick(object sender, EventArgs e)
  {
  string t= s.Substring(i, 1);

  textBox1.Text += t;
  i++;
  if (i > 17) timer1.Stop();
  }

  private void Form1_Load(object sender, EventArgs e)
  {
  timer1.Start();
  }
  }
}

c#  如何让光标随着文字往后移???




  
搜索更多相关主题的帖子: 如何 private public 国家 
2011-11-05 23:47
serious
Rank: 6Rank: 6
等 级:侠之大者
威 望:1
帖 子:81
专家分:497
注 册:2009-8-18
收藏
得分:10 
这个代码应该做你想:
程序代码:
using System;
using System.Windows.Forms;

namespace 文字
{
    public partial class Form1 : Form
    {
        private Timer timer1 = new Timer();
        private TextBox textBox1 = new TextBox()
        {
            Width = 250
        };
        private string s = "苟利国家生死以," + "\r\n" + "岂因祸福避趋之。";
        private int i = 0;

        public Form1()
        {
            this.Controls.Add(textBox1);

            this.Load += Form1_Load;
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            textBox1.Text += s[i];

            i++;

            if (i >= s.Length) timer1.Stop();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            timer1.Interval = 500;
            timer1.Tick += timer1_Tick;
            timer1.Start();
        }
    }

    class Test
    {
        static void Main()
        {
            Application.Run(new Form1());
        }
    }
}

2011-11-06 00:59
快速回复:如何让光标随着文字往后移???
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.011958 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved