[urgent] Message Box is non-modal in VB!

J

js

Hi,

In some situation, the message box can not be shown in modal mode.

Please drop a DateTimePicker control on a Form (VB project), show a
message box in the ValueChanged event, as below snippet. Now run the form
and drop down the calendar, select a date to let the event fire, after the
message box shown, we can still activate the form background. This happens
whatever MsgBoxStyle is specified even as MsgBoxStyle.SystemModal.


Private Sub DateTimePicker1_ValueChanged(ByVal sender As Object, ByVal e
As System.EventArgs) Handles DateTimePicker1.ValueChanged
MsgBox("DateTimePicker1_ValueChanged", MsgBoxStyle.ApplicationModal)
End Sub


The same scenario could be reproduced in a C# project, but I could pass it
if by specifying the Form as the owner of the message box, as below code.

private void dateTimePicker1_ValueChanged(object sender, System.EventArgs
e)
{
MessageBox.Show(this, "dateTimePicker1_ValueChanged");
}



Is something wrong in the message box method in VB?




-jason
 
J

Julia Lerman

Jason
You are partially right. I tried the datetimepicker and a few other
controls. So far it is only the date time picker that is ignoring the modal
state of the dialog box. Try a checkbox and put your msgbox in the
checkedChanged event or a button with a msgbox in the click event.

I could not find any info on this via google.

I will ask some more MVP's if they are familiar with this problem.

Julie Lerman
..NET MVP
 
J

js

Julie,

Yes, only the DateTimePicker has the issue. The reason I just choose
this control is I was constructing a custom dropdown control which I believe
has the similar window relationship as the DateTimePicker control. My
customer reported the non-modal problem to me and I immediately checked the
DateTimePicker, "luckily" it has the same problem.

I was trying to work around it but with no result, whatever both the
MsgBoxStyle.SystemModal and the MsgBoxStyle.ApplicationModal do not take
effect in this scenario. I have no idea whether this is a bug in the .NET
Framework.

Any .NET MVP could help?



-jason
 
J

Julia Lerman

I have put the question in as a possible bug.
Will post back as soon as I have some info for you.
I have seen other issues posted about the valuechanged event and msgbox.
julie
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top