hello friends,
how can i design a region in vb.net form(windows application), such that when i click any point inside a region a new page opens.
my problem is that the region which i want to define through it is very complex..its a combination of a rectangle and another shape.
thanks for your help:)

Create the region with a GraphicsPath

Dim GraphicsPath As New Drawing2D.GraphicsPath(Drawing2D.FillMode.Winding)
   GraphicsPath.AddRectangle(New Rectangle(10, 10, 110, 110))
   GraphicsPath.AddEllipse(New Rectangle(50, 50, 100, 100))

   Me.Region = New Region(GraphicsPath)

I may have read your post wrong.

This might be more of what your looking for.

Public Class Form1

    Private GraphicsPath As Drawing2D.GraphicsPath

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        GraphicsPath = New Drawing2D.GraphicsPath(Drawing2D.FillMode.Winding)
        GraphicsPath.AddRectangle(New Rectangle(10, 10, 110, 110))
        GraphicsPath.AddEllipse(New Rectangle(50, 50, 100, 100))

    End Sub

    Private Sub Form1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseClick
        If GraphicsPath.IsVisible(e.X, e.Y) Then
            MsgBox("Open a form")
        End If
    End Sub

    Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
        e.Graphics.DrawPath(Pens.Black, GraphicsPath)
    End Sub

End Class

thanx for the post...
what if i wanted a unique region and not these predefined regions.

The GraphicsPath has 14 Add methods. You say you want to create a region that is made up of a rectangle and another shape. What is the other Shape?

------------------------|
|
|
|-------------------------------------------------------
|
|
|
|
--------------------------------------------------------------------------------

Not exactly sure what that is. If that is supposed to be a solid area then you can create a polygon by defining the points.

Top Left Corner 0,0
Top Right Corner 50,0
Middle Right Corner 100,25
Bottom Right Corner 125,100
Bottom Left Corner 0,100

Put those points into a Point array and use the AddPolygon method of the Graphics Path.

So Something Like:

Dim CustomPolygon(4) as Point

CustomPolygon(0) = new point(0,0)
CustomPolygon(1) = new point(50,0)
.......

GraphicsPath.AddPolygon(CustomPolygon)
This article has been dead for over six months. Start a new discussion instead.