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. TableLayoutPanel in VB.Net 2005

TableLayoutPanel in VB.Net 2005

Scheduled Pinned Locked Moved Visual Basic
csharpcssdatabasehelp
3 Posts 2 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.
  • W Offline
    W Offline
    watagal
    wrote on last edited by
    #1

    I am trying to add a TableLayoutPanel (programatically). Here's what I have so far:

    Private Sub drawTableLayoutPanel()
            Dim iColumns As Integer = uxColumnsTbar.Maximum  ' Horizontal Trackbar
            Dim iRows As Integer = uxRowsTbar.Maximum        ' Vertical Trackbar
    '
            Dim oTLP As New TableLayoutPanel
            oTLP.Location = New Point(0, 0)
            oTLP.Size = New Size(500, 200)
            oTLP.AutoScroll = True
            oTLP.AutoSizeMode = Windows.Forms.AutoSizeMode.GrowAndShrink
            oTLP.GrowStyle = TableLayoutPanelGrowStyle.AddRows
            oTLP.CellBorderStyle = TableLayoutPanelCellBorderStyle.Inset
            '
            oTLP.ColumnCount = iColumns
            For c As Integer = 0 To (iColumns - 1)
                oTLP.ColumnStyles(c).SizeType = SizeType.Absolute  ' Errors HERE with c=0
                oTLP.ColumnStyles(c).Width = (1 / iColumns)
            Next
            '
            oTLP.RowCount = iRows
            For r As Integer = 0 To (iRows - 1)
                oTLP.RowStyles(r).SizeType = SizeType.Absolute
                oTLP.RowStyles(r).Height = (1 / iRows)
            Next
            '
            oTLP.Update()
        End Sub
    

    The error I get is:

    System.ArgumentOutOfRangeException was unhandled
    Message="Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index"

    Which collection are they referring to? iColumns=6 and iRows=4 - this has been verified. Thanks, Karen Nooobie to OOP and VB.Net 2005

    D W 2 Replies Last reply
    0
    • W watagal

      I am trying to add a TableLayoutPanel (programatically). Here's what I have so far:

      Private Sub drawTableLayoutPanel()
              Dim iColumns As Integer = uxColumnsTbar.Maximum  ' Horizontal Trackbar
              Dim iRows As Integer = uxRowsTbar.Maximum        ' Vertical Trackbar
      '
              Dim oTLP As New TableLayoutPanel
              oTLP.Location = New Point(0, 0)
              oTLP.Size = New Size(500, 200)
              oTLP.AutoScroll = True
              oTLP.AutoSizeMode = Windows.Forms.AutoSizeMode.GrowAndShrink
              oTLP.GrowStyle = TableLayoutPanelGrowStyle.AddRows
              oTLP.CellBorderStyle = TableLayoutPanelCellBorderStyle.Inset
              '
              oTLP.ColumnCount = iColumns
              For c As Integer = 0 To (iColumns - 1)
                  oTLP.ColumnStyles(c).SizeType = SizeType.Absolute  ' Errors HERE with c=0
                  oTLP.ColumnStyles(c).Width = (1 / iColumns)
              Next
              '
              oTLP.RowCount = iRows
              For r As Integer = 0 To (iRows - 1)
                  oTLP.RowStyles(r).SizeType = SizeType.Absolute
                  oTLP.RowStyles(r).Height = (1 / iRows)
              Next
              '
              oTLP.Update()
          End Sub
      

      The error I get is:

      System.ArgumentOutOfRangeException was unhandled
      Message="Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index"

      Which collection are they referring to? iColumns=6 and iRows=4 - this has been verified. Thanks, Karen Nooobie to OOP and VB.Net 2005

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

      Well, I've haven't used the TableLayoutPanel yet, but it looks like the TableLayoutPanel.ColumnStyles collection is empty. Just because you set the ColumnCount to whatever, doesn't mean that there are any ColumnStyle objects added to the ColumnStylesCollection your trying to index.

      For c As Integer = 0 To (iColumns - 1)
      Dim newColStyle = New ColumnStyle(SizeType.Absolute, 1/iColumns)
      Next

      RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

      1 Reply Last reply
      0
      • W watagal

        I am trying to add a TableLayoutPanel (programatically). Here's what I have so far:

        Private Sub drawTableLayoutPanel()
                Dim iColumns As Integer = uxColumnsTbar.Maximum  ' Horizontal Trackbar
                Dim iRows As Integer = uxRowsTbar.Maximum        ' Vertical Trackbar
        '
                Dim oTLP As New TableLayoutPanel
                oTLP.Location = New Point(0, 0)
                oTLP.Size = New Size(500, 200)
                oTLP.AutoScroll = True
                oTLP.AutoSizeMode = Windows.Forms.AutoSizeMode.GrowAndShrink
                oTLP.GrowStyle = TableLayoutPanelGrowStyle.AddRows
                oTLP.CellBorderStyle = TableLayoutPanelCellBorderStyle.Inset
                '
                oTLP.ColumnCount = iColumns
                For c As Integer = 0 To (iColumns - 1)
                    oTLP.ColumnStyles(c).SizeType = SizeType.Absolute  ' Errors HERE with c=0
                    oTLP.ColumnStyles(c).Width = (1 / iColumns)
                Next
                '
                oTLP.RowCount = iRows
                For r As Integer = 0 To (iRows - 1)
                    oTLP.RowStyles(r).SizeType = SizeType.Absolute
                    oTLP.RowStyles(r).Height = (1 / iRows)
                Next
                '
                oTLP.Update()
            End Sub
        

        The error I get is:

        System.ArgumentOutOfRangeException was unhandled
        Message="Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index"

        Which collection are they referring to? iColumns=6 and iRows=4 - this has been verified. Thanks, Karen Nooobie to OOP and VB.Net 2005

        W Offline
        W Offline
        watagal
        wrote on last edited by
        #3

        Thanks Dave, that got me past the error message. I still don't get a TableLayoutPanel Control on my at runtime, but I'll post a new message with an appropriate subject title. Thanks again, Karen Nooobie to OOP and VB.Net 2005

        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