For show text different way in windows forms output using marquee
and timer control follow the below
steps:
First design one window form using C#.net.
Take one label , Timer control and one Stop button from toolbox
set some properties if required.
Then the form looks like below , in that I am taking label text as
welcome and timer control interval property 100 and button name as Stop.
Then write the following code in form_load, Timer_Tick event and
stop button_Click event:
In Form load I am giving label text as Naresh and start the timer
control.
In Timer Control click event I am showing text like marquee.
In Stop button click I am stopping text to normal.
public partial class Form1 : Form
{
private int
xPos = 0;
public Form1()
{
InitializeComponent();
}
private void
timer1_Tick(object sender, EventArgs e)
{
if
(this.Width == xPos)
{
//repeat
marquee
this.label1
.Location = new System.Drawing.Point(0, 40);
xPos = 0;
}
else
{
this.label1.Location
= new System.Drawing.Point(xPos,
40);
xPos++;
}
}
private void
Form1_Load(object sender, EventArgs e)
{
timer1.Start();
label1.Text = "naresh";
}
private void
button1_Click(object sender, EventArgs e)
{
timer1.Stop();
}
}
Then Show Output like below:
0 comments:
Post a Comment