check my code..TableLayoutPanel in vb.net
-
when u select any cell in tablelayoutpanel i need to show selection Handlers around the cell ..But it's not dispalaying correct way.. Public Class Form8 Const Handle_Size As Integer = 6 Dim iwidth As Integer Dim iHeigt As Integer Dim ileft As Integer Dim itop As Integer Private Sub TaleLayoutPanel1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TableLayoutPanel1.MouseDown Dim widths As Integer() = TableLayoutPanel1.GetColumnWidths() Dim heights As Integer() = TableLayoutPanel1.GetRowHeights() Dim col As Integer = -1 Dim left As Integer = e.X For i As Integer = 0 To widths.Length - 1 If left < widths(i) Then col = i iwidth = widths(i) Exit For Else left -= widths(i) End If ileft += widths(i) Next Dim row As Integer = -1 Dim top As Integer = e.Y For i As Integer = 0 To heights.Length - 1 If top < heights(i) Then row = i iHeigt = heights(i) Exit For Else top -= heights(i) End If itop += heights(i) Next DrawControlBorder(sender) End Sub Private Sub DrawControlBorder(ByVal sender As Object) Dim control As Control = DirectCast(sender, Control) Dim Border As New Rectangle(New Point(control.Location.X + ileft - Handle_Size / 2, control.Location.Y + itop - Handle_Size / 2), New Size(iwidth + Handle_Size, iHeigt + Handle_Size)) Dim NW As New Rectangle(New Point(control.Location.X + ileft - Handle_Size, control.Location.Y + itop - Handle_Size), New Size(Handle_Size, Handle_Size)) Dim N As New Rectangle(New Point(control.Location.X + ileft + iwidth / 2 - Handle_Size / 2, control.Location.Y + itop - Handle_Size), New Size(Handle_Size, Handle_Size)) Dim NE As New Rectangle(New Point(control.Location.X + ileft + iwidth, control.Location.Y + itop - Handle_Size), New Size(Handle_Size, Handle_Size)) Dim W As New Rectangle(New Point(control.Location.X + ileft - Handle_Size, control.Location.Y + itop + iHeigt / 2 - Handle_Size / 2), New Size(Handle_Size, Handle_Size)) Dim E As New Rectangle(New Point(control.Location.X + ileft + iwidth, control.Location.Y + itop + iHeigt / 2 - Handle_Size / 2), New Size(Handle_Size, Handle_Size)) Dim
-
when u select any cell in tablelayoutpanel i need to show selection Handlers around the cell ..But it's not dispalaying correct way.. Public Class Form8 Const Handle_Size As Integer = 6 Dim iwidth As Integer Dim iHeigt As Integer Dim ileft As Integer Dim itop As Integer Private Sub TaleLayoutPanel1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TableLayoutPanel1.MouseDown Dim widths As Integer() = TableLayoutPanel1.GetColumnWidths() Dim heights As Integer() = TableLayoutPanel1.GetRowHeights() Dim col As Integer = -1 Dim left As Integer = e.X For i As Integer = 0 To widths.Length - 1 If left < widths(i) Then col = i iwidth = widths(i) Exit For Else left -= widths(i) End If ileft += widths(i) Next Dim row As Integer = -1 Dim top As Integer = e.Y For i As Integer = 0 To heights.Length - 1 If top < heights(i) Then row = i iHeigt = heights(i) Exit For Else top -= heights(i) End If itop += heights(i) Next DrawControlBorder(sender) End Sub Private Sub DrawControlBorder(ByVal sender As Object) Dim control As Control = DirectCast(sender, Control) Dim Border As New Rectangle(New Point(control.Location.X + ileft - Handle_Size / 2, control.Location.Y + itop - Handle_Size / 2), New Size(iwidth + Handle_Size, iHeigt + Handle_Size)) Dim NW As New Rectangle(New Point(control.Location.X + ileft - Handle_Size, control.Location.Y + itop - Handle_Size), New Size(Handle_Size, Handle_Size)) Dim N As New Rectangle(New Point(control.Location.X + ileft + iwidth / 2 - Handle_Size / 2, control.Location.Y + itop - Handle_Size), New Size(Handle_Size, Handle_Size)) Dim NE As New Rectangle(New Point(control.Location.X + ileft + iwidth, control.Location.Y + itop - Handle_Size), New Size(Handle_Size, Handle_Size)) Dim W As New Rectangle(New Point(control.Location.X + ileft - Handle_Size, control.Location.Y + itop + iHeigt / 2 - Handle_Size / 2), New Size(Handle_Size, Handle_Size)) Dim E As New Rectangle(New Point(control.Location.X + ileft + iwidth, control.Location.Y + itop + iHeigt / 2 - Handle_Size / 2), New Size(Handle_Size, Handle_Size)) Dim
Your question is not answerable. How are we supposed to know what you define as the "correct way" since you didn't provide any information on what you expect this code to do?? And cells in a TableLayoutPanel are not selectable at runtime, so I have no idea what you're trying to do with this...
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008 -
Your question is not answerable. How are we supposed to know what you define as the "correct way" since you didn't provide any information on what you expect this code to do?? And cells in a TableLayoutPanel are not selectable at runtime, so I have no idea what you're trying to do with this...
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008 -
Has anyone else noticed that we're being overrun by the Nation of Idiocracy? I hate that people just drive-by and 1 vote, or the OP 1-votes the response because it didn't come with a completely coded solution they could copy-n-paste.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008 -
Has anyone else noticed that we're being overrun by the Nation of Idiocracy? I hate that people just drive-by and 1 vote, or the OP 1-votes the response because it didn't come with a completely coded solution they could copy-n-paste.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008It's been running rampant lately, in all forums. The worst is in the SB, you can get hammered there. I'm learning slowly to not get baited into posting in there. But yeah, give a reply the OP doesn't like (example, how can I make my application unterminatable by even the TaskManager = NO) you get 1 voted. It's quite annoying.