Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. check my code..TableLayoutPanel in vb.net

check my code..TableLayoutPanel in vb.net

Scheduled Pinned Locked Moved Visual Basic
csharp
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    dilipmca04
    wrote on last edited by
    #1

    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

    D 1 Reply Last reply
    0
    • D dilipmca04

      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

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      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

      L 1 Reply Last reply
      0
      • D Dave Kreskowiak

        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

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        Tried to balance the 1 you got there, a horrid question indeed.

        D 1 Reply Last reply
        0
        • L Lost User

          Tried to balance the 1 you got there, a horrid question indeed.

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          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

          L 1 Reply Last reply
          0
          • D Dave Kreskowiak

            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

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            It'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.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups