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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Dipa AhujaRank #1,168 · 1.5K reputationPosted May 16, 2010, 8:13 AM EDT
Daniel Ivicic16 reputationPosted May 16, 2010, 8:16 AM EDT
{
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 AhujaRank #1,168 · 1.5K reputationPosted May 16, 2010, 8:19 AM EDT
Kirtan PatelRank #292 · 8.6K reputationPosted May 16, 2010, 8:20 AM EDT
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;
}
}
Daniel Ivicic16 reputationPosted May 16, 2010, 8:46 AM EDT
did you tried it? works?
Dipa AhujaRank #1,168 · 1.5K reputationPosted May 16, 2010, 8:55 AM EDT
Jaish MathewsRank #225 · 11K reputationPosted May 16, 2010, 9:04 AM EDT
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;
}
Daniel Ivicic16 reputationPosted May 16, 2010, 9:12 AM EDT
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 MathewsRank #225 · 11K reputationPosted May 16, 2010, 9:21 AM EDT
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.