Hello all,
i did tried google it, but cant find
is there any way to hide picturebox automaticly after 10seconds when
window form is loaded?
please code example
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Jaish MathewsPosted May 16, 2010, 1:21 PM
Set the timer properties in in design time rather than inside coding.
More over remove those casting and all. Just write the code "pictureBox1.Visible = false".
This looks neat.
Daniel IvicicPosted May 16, 2010, 1:12 PM
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
// Instantiate the timer
t1 = new Timer();
// Setup timer
t1.Interval = 1000; //1000ms = 1sec
t1.Tick += new EventHandler(t1_Tick);
t1.Start();
}
void t1_Tick(Object Sender, EventArgs e)
{
if (pictureBox1.Visible == true)
{
pictureBox1.Visible = false;
((Timer)Sender).Enabled = false;
}
}
private void pictureBox1_Click(object sender, EventArgs e)
{
}
}
}
Jaish MathewsPosted May 16, 2010, 1:04 PM
You please check the below properties of your timer control.
Enabled should be "True". By default it's false
Intervel should be 10000 i.e. 10 sec.
Then only write below code
private void timer1_Tick(object sender, EventArgs e)
{
pictureBox1.Visible = false;
}
Dipa AhujaPosted May 16, 2010, 12:55 PM
Daniel IvicicPosted May 16, 2010, 12:46 PM
did you tried it? works?
Kirtan PatelPosted May 16, 2010, 12:20 PM
private void Form1_Load(object sender, EventArgs e)
{
Timer t1 = new Timer();
t1.Interval = 10000;
t1.Tick +=new EventHandler(t1_Tick);
t1.Enabled = true;
}
void t1_Tick(Object Sender, EventArgs e)
{
if (pictureBox1.Visible == true)
{
pictureBox1.Visible = false;
((Timer)Sender).Enabled = false;
}
}
Dipa AhujaPosted May 16, 2010, 12:19 PM
Daniel IvicicPosted May 16, 2010, 12:16 PM
{
this.Hide();
}
i get it, but i dont know code to hide only picturebox1, i figured timer out, but dunno code to hide only picturebox1, this.hide hides entire form
Dipa AhujaPosted May 16, 2010, 12:13 PM