Some time you face an error message ‘#Region’ and ‘#End Region’ statements are not valid within method bodies/multiline lambdas, the main reason is that you does not put these statements at right place.
The #Region and #End Region statements block must be declared at a class, module, or namespace level. A collapsible region can include one or more procedures, but it cannot begin or end inside of a procedure. So to correct this error ensure that the #Region and #End Region statements are in the same code block. May be you are using both statements in correct way.
Basically #Region directive to specify a block of code to expand or collapse when using the outlining feature of the Visual Studio Code Editor. #Region statements support block semantics that means the start and end must be in the same code block. You can place, or nest, regions within other regions to group similar regions together.
You can use the #Region as :
#Region "fgfg" Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs) MyBase.OnPaint(e) 'Add your custom paint code here End Sub #End Region