RE: Timer and Random

Tech-Archive recommends: Fix windows errors by optimizing your registry



Hi Venu,

OnTimerEvent(object source, EventArgs e), method is not a static method, its
a reference method.

public void OnTimerEvent(object source, EventArgs e)
{
// 8 pictures
Random objRandom= new Random();
int num= objRandom.Next(1,8);

Presentation obj= new Presentation(); /// presentation is the name of
//the class
if(num.ToString()=="1")
{
obj.DisplayCRMInfo(); ///// this function is as below
obj.Refresh();
return;
}
////// 7 more ifs follow
}

try it now ... GoodLuck... Veera Sekhar...

"VenuGopal" wrote:

> hi,
> i have a WELCOME screen. here i have a PICTURE BOX. there are 8 pictures
> that go into this Picture Box.
>
> At every 5 seconds i want to RANDOMLY load a new Picture.
> this is what i am using but it is not loading the new picture.
> Can any one help?
>
>
> public void Presentation_Load(object sender, System.EventArgs e)
> {
> Timer timer1= new Timer();
> timer1.Interval = 5000;
> timer1.Enabled = true;
> timer1.Tick += new System.EventHandler (OnTimerEvent);
> }
>
> public static void OnTimerEvent(object source, EventArgs e)
> {
> // 8 pictures
> Random objRandom= new Random();
> int num= objRandom.Next(1,8);
>
> Presentation obj= new Presentation(); /// presentation is the name of
> the class
> if(num.ToString()=="1")
> {
> obj.DisplayCRMInfo(); ///// this function is as below
> obj.Refresh();
> return;
> }
> ////// 7 more ifs follow
> }
>
> public void DisplayCRMInfo()
> {
> string picture = Application.StartupPath +@"\Presentation\CRM.jpg";
> pictureBox1.Image = Image.FromFile(picture);
> }
>
>
>
.



Relevant Pages

  • Re: saving picture to a user profile!
    ... Jeff wrote: ... "The property 'Picture' could not be created from it's default value. ... protected void Button1_Click(object sender, EventArgs e) ... HttpPostedFile file = FileUpload1.PostedFile; ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: MessageBox questions
    ... > public void Page_Load(Object sender, EventArgs e) { ... > this script work in a web client application? ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: saving picture to a user profile!
    ... "The property 'Picture' could not be created from it's default value. ... protected void Button1_Click(object sender, EventArgs e) ... HttpPostedFile file = FileUpload1.PostedFile; ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Generics and static members
    ... public void MethodB() ... If this is the case, then it's not possible for the compiler to fulfill your intent, because it needs to know when it compiles the _generic_ class how to get at the method, and at that point the type parameter hasn't actually been resolved yet. ... the compiler could generate some complex code to use reflection to determine at run-time the correct static method to call. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: My First C# (warning - long post)
    ... add(entry, entry); ... public void makeAnimalSound ... AnimalNoiseGenerator noiseGenerator = dictionary.get ... one of this objects vs calling a static method. ...
    (comp.lang.cobol)