# hexagonal grid Mouse over

I've been trying to workout the code that calculates the correct row and column in the mouse is over event the following is the code I'm using to draw the grid Tile are 64x64.

Private Sub Form1_Paint(sender As Object, e As PaintEventArgs) Handles MyBase.Paint
Dim mDestRect As Rectangle

Dim mX As Int32 = 0
Dim mY As Int32 = 0

Using mFont As New Font("Segoe UI", 7.0F, FontStyle.Bold, GraphicsUnit.Point)
Using mBrush As New SolidBrush(Color.FromArgb(128, Color.Black))
For row As Int32 = 0 To 9
For column As Int32 = 0 To 9

If (row Mod 2) = 1 Then
mX = (column * mTileWidth) + 32
Else
mX = column * mTileWidth
End If

mY = (row * mTileHeight) - (row * 16)

mDestRect = New Rectangle(mX, mY, mTile.Width, mTile.Height)
e.Graphics.DrawImage(mTile, mDestRect, mSrc, GraphicsUnit.Pixel)

Dim mREct As New Rectangle(mX + mTile.Width * 0.25F, mY + mTile.Height * 0.25F, mTile.Width * 0.5F, mTile.Height * 0.5F)
e.Graphics.FillEllipse(mBrush, mREct)

TextRenderer.DrawText(e.Graphics, String.Format("[{0},{1}]", column, row), mFont, mDestRect, Color.White, TextFormatFlags.NoPadding Or TextFormatFlags.VerticalCenter Or TextFormatFlags.HorizontalCenter)

Next column
Next row
End Using
End Using
End Sub


can anybody help please

• You shouldn't use the <code> tags for multiline code – Bálint Nov 12 '16 at 15:49
• You may find this answer useful – DMGregory Nov 12 '16 at 15:54
• I tried just to post the code but it did not help either way.DMGregory not really could see what I was looking for in it – Jason Howells Nov 12 '16 at 16:17
• @JasonHowells It's exactly about your problem. IMO this should be closed as duplicate. Also, use a @ before the names, so they get a message that you answered, and read this: stackoverflow.com/editing-help – Bálint Nov 12 '16 at 18:22
• @Bálint I'm not sure what you mean, duplicate of what? I'm still not seeing the answer to the question. – Jason Howells Nov 12 '16 at 19:09