messageBox keeps...showing up !

  • Thread starter Thread starter arr uba
  • Start date Start date
A

arr uba

hi all!

I don't know why, but I've just inserted the following code:
private void monthCalendar1_click(object sender, DateRangeEventArgs e)

{

MessageBox.Show("hello");

}



....and when running my form and clicking on my calendar i will get the
message box "hello" not once but repeatedly from time to time.

Any idea why?

Thanks.
 
hi all!

I don't know why, but I've just inserted the following code:
private void monthCalendar1_click(object sender, DateRangeEventArgs e)

{

MessageBox.Show("hello");

}

...and when running my form and clicking on my calendar i will get the
message box "hello" not once but repeatedly from time to time.

Any idea why?

Thanks.

put a breakpoint and see who is calling it
 
hi all!

I don't know why, but I've just inserted the following code:
private void monthCalendar1_click(object sender, DateRangeEventArgs e)

{

MessageBox.Show("hello");

}



...and when running my form and clicking on my calendar i will get the
message box "hello" not once but repeatedly from time to time.

Any idea why?
The event fires every time the control is clicked and not just for the
first click.

regards
A.G.
 
Fair enough! I'm sending you the code.
I've replicated it in a very small example.
The sample does not exhibit the behavior you have described.
I appreciate all your help...I'm just a newbye, and I'm sure this is just
something I'm missing:

- once you you run it in Visual C# Express IDE, then the pop-up message will
reappear again about 1 minute later...an so on...
I am unfamiliar with the Express tools but the tool shouldn't matter.
The behavior you describe shouldn't happen and I have no idea why it
is occurring on your machine. Sorry I can be of any assistance.

regards
A.G.
 
arr uba said:
Fair enough! I'm sending you the code.
I've replicated it in a very small example.

I appreciate all your help...I'm just a newbye, and I'm sure this is just
something I'm missing:

- once you you run it in Visual C# Express IDE, then the pop-up message
will reappear again about 1 minute later...an so on...

Cheers,


The code runs as expected (1 msgbox per click) for me with VS 2008 Express.

It should be noted though that you are actually handling the
selected_datechanged event, which can come by using the arrow keys to change
the date.

You might want to examine the eventargs and sender parameters in the
debugger to see why this may occur on your machine.
 
Hi AG,

Yeah, same effect on my computer.
If I click on date, it work correctly.
If clicked on month or year, it will display twice.
If I click on left/right navigation button, it will display forever...
If I change MessageBox to Console.WriteLine, same result (though it will
display only twice instead of forever).

I don't know if it is a bug or not, maybe someone else have the explanation.

using System;
using System.Windows.Forms;

namespace Foo
{
class Form1 : Form
{
private MonthCalendar monthCalendar1;

public Form1()
{
InitializeComponent();
}

private void InitializeComponent()
{
monthCalendar1 = new MonthCalendar();
monthCalendar1.DateChanged += new
DateRangeEventHandler(monthCalendar1_DateChanged);
Controls.Add(monthCalendar1);
}

private void monthCalendar1_DateChanged(object sender,
DateRangeEventArgs e)
{
MessageBox.Show("hello");
//Console.WriteLine("hello");
}

[STAThread]
public static void Main(string[] args)
{
Application.Run(new Form1());
}
}
}
 
Hi Kndg,
thanks for displaying the code.

Could this behaviour only happen while working on the IDE ambient? Could be
just a bug from VC#express ?




kndg said:
Hi AG,

Yeah, same effect on my computer.
If I click on date, it work correctly.
If clicked on month or year, it will display twice.
If I click on left/right navigation button, it will display forever...
If I change MessageBox to Console.WriteLine, same result (though it will
display only twice instead of forever).

I don't know if it is a bug or not, maybe someone else have the
explanation.

using System;
using System.Windows.Forms;

namespace Foo
{
class Form1 : Form
{
private MonthCalendar monthCalendar1;

public Form1()
{
InitializeComponent();
}

private void InitializeComponent()
{
monthCalendar1 = new MonthCalendar();
monthCalendar1.DateChanged += new
DateRangeEventHandler(monthCalendar1_DateChanged);
Controls.Add(monthCalendar1);
}

private void monthCalendar1_DateChanged(object sender,
DateRangeEventArgs e)
{
MessageBox.Show("hello");
//Console.WriteLine("hello");
}

[STAThread]
public static void Main(string[] args)
{
Application.Run(new Form1());
}
}
}

arr said:
Fair enough! I'm sending you the code.
I've replicated it in a very small example.

I appreciate all your help...I'm just a newbye, and I'm sure this is just
something I'm missing:

- once you you run it in Visual C# Express IDE, then the pop-up message
will reappear again about 1 minute later...an so on...

Cheers,
 
Hi Kndg,
thanks for displaying the code.

Could this behaviour only happen while working on the IDE ambient? Could be
just a bug from VC#express ?

kndg said:
Yeah, same effect on my computer.
If I click on date, it work correctly.
If clicked on month or year, it will display twice.
If I click on left/right navigation button, it will display forever...
If I change MessageBox to Console.WriteLine, same result (though it will
display only twice instead of forever).
I don't know if it is a bug or not, maybe someone else have the
explanation.
using System;
using System.Windows.Forms;
namespace Foo
{
  class Form1 : Form
  {
    private MonthCalendar monthCalendar1;
    public Form1()
    {
      InitializeComponent();
    }
    private void InitializeComponent()
    {
      monthCalendar1 = new MonthCalendar();
      monthCalendar1.DateChanged += new
DateRangeEventHandler(monthCalendar1_DateChanged);
      Controls.Add(monthCalendar1);
    }
    private void monthCalendar1_DateChanged(object sender,
DateRangeEventArgs e)
    {
      MessageBox.Show("hello");
      //Console.WriteLine("hello");
    }
    [STAThread]
    public static void Main(string[] args)
    {
      Application.Run(new Form1());
    }
  }
}

I doubt it
 
Hi,

No, the bug is from the framework itself (I reproduce it using Notepad
and command line).
Someone had posted the bug to Microsoft connect and they will try to fix
it on their next release (though the problem had been surface since 2003).
http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=412392

You may try a workaround suggested by people at MSDN forum.
http://social.msdn.microsoft.com/Forums/en-US/winforms/thread/3b105f6c-3926-4962-935b-9a76c1be1750/

Regards.

arr said:
Hi Kndg,
thanks for displaying the code.

Could this behaviour only happen while working on the IDE ambient? Could be
just a bug from VC#express ?




kndg said:
Hi AG,

Yeah, same effect on my computer.
If I click on date, it work correctly.
If clicked on month or year, it will display twice.
If I click on left/right navigation button, it will display forever...
If I change MessageBox to Console.WriteLine, same result (though it will
display only twice instead of forever).

I don't know if it is a bug or not, maybe someone else have the
explanation.

using System;
using System.Windows.Forms;

namespace Foo
{
class Form1 : Form
{
private MonthCalendar monthCalendar1;

public Form1()
{
InitializeComponent();
}

private void InitializeComponent()
{
monthCalendar1 = new MonthCalendar();
monthCalendar1.DateChanged += new
DateRangeEventHandler(monthCalendar1_DateChanged);
Controls.Add(monthCalendar1);
}

private void monthCalendar1_DateChanged(object sender,
DateRangeEventArgs e)
{
MessageBox.Show("hello");
//Console.WriteLine("hello");
}

[STAThread]
public static void Main(string[] args)
{
Application.Run(new Form1());
}
}
}

arr said:
Fair enough! I'm sending you the code.
I've replicated it in a very small example.

I appreciate all your help...I'm just a newbye, and I'm sure this is just
something I'm missing:

- once you you run it in Visual C# Express IDE, then the pop-up message
will reappear again about 1 minute later...an so on...

Cheers,



"Peter Duniho" <[email protected]> escreveu na mensagem
Hi AG,

what you say makes sense...but I only clicked it once...
Then what else is calling your event handler?

The fact is, assuming that's the only place you call
MessageBox.Show("hello"), then the only way for you to get more than one
message box is for your event handler to be called more than once.
Either
it's not actually true that you "only clicked it once", or you have some
other mechanism that results in the event handler being called.

Since you haven't posted a concise-but-complete code example that
reliably
demonstrates the problem, there's nothing anyone can do except point out
the obvious (as above). If you want real help, you need to post a
concise-but-complete code example that reliably demonstrates the
problem.
Be sure to provide detailed, specific instructions as to how to use the
code to reproduce the behavior.

Pete
 
Back
Top