Recommended: Three solutions for visual studio real-time debugger always pops up Recently, the server has been popping up the visual studio real-time debugger, which is very depressing. It can't be turned off. How to solve it? As shown in the figure below: Let's analyze the reason for this situation together: Pop-up application: Visual Studio Real-time Debugger: An unhandled exception occurred (subscript out of bounds: '[number: 0] '), the occurrence location is w3wp.exe [2472].
The beginning of the problem was raised by C# transmission and reading the main group. Let me talk about the solution below
Actually, it looks very simple on the surface
Let's start, now there are two forms Form1 main form and Form2 subform
And I believe most people will write this
In the Load event of a child form
Written like this
this.StartPosition = FormStartPosition.CenterParent;
In fact, it is wrong to write this way, the correct way should be
this.StartPosition = FormStartPosition.CenterScreen;
Why CenterScreen instead of CenterParent?
That's because of the problem with the method we call, if you write this when calling the child form
Form2 f2 = new Form2();
f2.MdiParent = this;
f2.Show();
Then you have to use CenterScreen instead of CenterParent, because when the form is an Owner page, not a Parent, when the show is a form.
Only when using CenterParent is used when using ShowDialog() method
Will you say that this is enough? Actually, it is not possible. Our code should not be written in the Load event, but before the Show method.
The correct way to write it should be like this
Form2 f2 = new Form2();
f2.MdiParent = this;
f2.StartPosition = FormStartPosition.CenterScreen;
f2.Show();
You need to do nothing in the child form
The following is an example I provided, which is the source code. If you still don’t know much, you can download the example and take a look at it.
The actual properties of a layout
The StartPosition property has the following options, and the meanings are as follows:
The CenterParent form is centered in its parent form.
The CenterScreen form is centered in the current display window and its size is specified in the form size.
The location of the Manual form is determined by the Location property.
The WindowsDefaultBounds form is positioned in the Windows default location, and its boundaries are also determined by the Windows default.
The WindowsDefaultLocation form is positioned in the Windows default location, and its size is specified in the form size.
CenterScreen does not mean that the screen is centered (relative), it is centered in the current display window.
Share: Asp effectively prevents spam/comments from happening on the website message board 1. Fill in the page on the form: input name=intime1 type=hidden value=%=Now()% On the submission processing page, set the submission time code as follows: If DateDiff(s,request.form(intime1), Now()) 5 then response.write SCRIPT language=JavaScriptalert('Your message is too fast, please stop leaving messages!'); response.write