您的位置:程序门 -> .net技术 -> c#



如何在textbox里面实现走马灯?


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


如何在textbox里面实现走马灯?[已结贴,结贴人:hanxueniao]
发表于:2007-09-07 08:50:18 楼主
我要在窗体上面设置一个公告,公告上面的字希望是走马灯样式的.从右往左移动.

  请大家指点下如何来实现.谢谢.
发表于:2007-09-07 09:07:521楼 得分:0
sf
发表于:2007-09-07 09:14:542楼 得分:0
web?一样用的啊
发表于:2007-09-07 09:15:493楼 得分:0
是winform
发表于:2007-09-07 09:17:424楼 得分:20
int       i;      
    bool       flag       =       false;      
    private       void       button4_click(object       sender,       system.eventargs       e)      
    {      
    this.textbox1.text       =       "123456789 ";      
    i       =       0;      
    timer       timer       =       new       timer();      
    timer.tick       +=       new       eventhandler(timer_tick);      
    timer.interval       =       100;      
    this.textbox1.focus();      
    this.textbox1.select(0,1);      
    timer.start();      
    }      
       
    private       void       timer_tick(object       sender,       system.eventargs       e)      
    {      
    if(this.i       ==       this.textbox1.text.length       )      
    {      
    this.flag       =       true;      
    }      
       
    if(this.i       ==       0       )      
    {      
    this.flag       =       false;      
    }      
       
       
    if(this.flag)      
    {      
    this.textbox1.selectionstart       =       --i;      
    }      
    else      
    {      
    this.textbox1.selectionstart       =       ++i;      
    }      
    }

很简单,你可以试试

发表于:2007-09-07 09:24:085楼 得分:0
這timer是   forms.timer     還是   threading.timer?
发表于:2007-09-07 09:25:176楼 得分:0
或者是timers.timer
发表于:2007-09-07 09:27:347楼 得分:10
private   void   form1_load(object   sender,   eventargs   e)
{
        timer1.enabled   =   true;
        timer1.interval   =   500;   //   零点五秒滚动一次
}

private   string   strinfo   =   "滚动的文字        ";   //   加适当的中文空格
private   int   pos   =   0;
private   void   timer1_tick(object   sender,   eventargs   e)
{
        textbox1.text   =   strinfo.substring(pos)   +   strinfo.remove(pos);
        pos   =   (pos   +   1)   %   strinfo.length;
}
发表于:2007-09-07 09:29:588楼 得分:0
forms.timer
发表于:2007-09-07 09:30:129楼 得分:0
timer   你没有用过吗
发表于:2007-09-07 09:32:0010楼 得分:0
咯..我試了下..
        是鼠标的光标在不停的走马灯..文字没有实现走马灯....
发表于:2007-09-07 09:39:3911楼 得分:0
你可以改改啊,在事件里写上不就可以了吗,都是一个道理
发表于:2007-09-07 09:41:0412楼 得分:0
呵呵   大概明白了     结贴.


快速检索

最新资讯
热门点击