PDA

View Full Version : حرکت متن درون یک تکس باکس



forodo007
سه شنبه 24 اسفند 1389, 20:37 عصر
من میخوام بدونم چطوری میشه متن درون یک تکس باکی به حرکت در بیاد یه چیزی مثل دستور marquee درون وب

exlord
سه شنبه 24 اسفند 1389, 22:33 عصر
public class Marquee:TextBox
{
SolidBrush b;
PointF location;
Timer t;
public Marquee()
{
this.SetStyle(ControlStyles.UserPaint, true);
b = new SolidBrush(this.ForeColor);
location = new PointF(0, 2);
t = new Timer();
t.Interval = 10;
t.Tick += new EventHandler(t_Tick);
t.Start();
}

void t_Tick(object sender, EventArgs e)
{
location.X--;
this.Invalidate();
}

protected override void OnPaint(PaintEventArgs e)
{
//base.OnPaint(e);
e.Graphics.DrawString(this.Text, this.Font, b, location);
}
}