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. Dynamically creating controls with TableLayoutPanel Contrrols

Dynamically creating controls with TableLayoutPanel Contrrols

Scheduled Pinned Locked Moved Visual Basic
graphicsquestion
2 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.
  • P Offline
    P Offline
    pavya_Cool
    wrote on last edited by
    #1

    Hi to all, I am trying to dynamically create label controls on TableLayoutPanel control, so that i have wrote following code. but at the debugging time it will genarate all the lables, but it doesnt show that panel as output. I checked its visible property its always false.... any body know why this happened? Public Sub fillTablePanel(ByVal ds As DataSet, ByVal TableName As String) FormContent.TablePanel.Parent = FormContent FormContent.TablePanel.Visible = True FormContent.TablePanel.BackColor = System.Drawing.SystemColors.ActiveCaptionText FormContent.TablePanel.CellBorderStyle = System.Windows.Forms.TableLayoutPanelCellBorderStyle.OutsetPartial Dim tRows, tCols As Integer FormContent.TablePanel.ColumnCount = ds.Tables(TableName).Columns.Count For tCols = 0 To ds.Tables(TableName).Columns.Count - 1 FormContent.TablePanel.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100 / (ds.Tables(TableName).Columns.Count))) Next FormContent.TablePanel.RowCount = ds.Tables(TableName).Rows.Count For tRows = 0 To ds.Tables(TableName).Rows.Count - 1 FormContent.TablePanel.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100 / (ds.Tables(TableName).Rows.Count))) Next ReDim FormContent.lblHeader(ds.Tables(TableName).Columns.Count) For tCols = 0 To ds.Tables(TableName).Columns.Count - 1 FormContent.lblHeader(tCols) = New Label() FormContent.TablePanel.Controls.Add(FormContent.lblHeader(tCols), tCols, 0) FormContent.lblHeader(tCols).Text = Convert.ToString(ds.Tables(TableName).Columns.Item(tCols)) FormContent.lblHeader(tCols).Location = New Point(FormContent.TablePanel.Location.X, 10) FormContent.lblHeader(tCols).Visible = True FormContent.lblHeader(tCols).AutoSize = True Next FormContent.TablePanel.Location = New System.Drawing.Point(221, 46) FormContent.TablePanel.Name = "TablePanel" FormContent.TablePanel.RowCount = 2 Dim x As Integer = ds.Tables(TableName).Columns.Count Dim y As Integer = ds.Tables(TableName).Rows.Count ReDim FormContent.lblContent(x * y) Dim ctr As Integer = 0 For tRows = 0 To ds.Tables(TableName).Rows.Count - 1 For tCols = 0 To ds.Tables(TableName).Columns.Count - 1 FormContent.lblConten

    M 1 Reply Last reply
    0
    • P pavya_Cool

      Hi to all, I am trying to dynamically create label controls on TableLayoutPanel control, so that i have wrote following code. but at the debugging time it will genarate all the lables, but it doesnt show that panel as output. I checked its visible property its always false.... any body know why this happened? Public Sub fillTablePanel(ByVal ds As DataSet, ByVal TableName As String) FormContent.TablePanel.Parent = FormContent FormContent.TablePanel.Visible = True FormContent.TablePanel.BackColor = System.Drawing.SystemColors.ActiveCaptionText FormContent.TablePanel.CellBorderStyle = System.Windows.Forms.TableLayoutPanelCellBorderStyle.OutsetPartial Dim tRows, tCols As Integer FormContent.TablePanel.ColumnCount = ds.Tables(TableName).Columns.Count For tCols = 0 To ds.Tables(TableName).Columns.Count - 1 FormContent.TablePanel.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100 / (ds.Tables(TableName).Columns.Count))) Next FormContent.TablePanel.RowCount = ds.Tables(TableName).Rows.Count For tRows = 0 To ds.Tables(TableName).Rows.Count - 1 FormContent.TablePanel.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100 / (ds.Tables(TableName).Rows.Count))) Next ReDim FormContent.lblHeader(ds.Tables(TableName).Columns.Count) For tCols = 0 To ds.Tables(TableName).Columns.Count - 1 FormContent.lblHeader(tCols) = New Label() FormContent.TablePanel.Controls.Add(FormContent.lblHeader(tCols), tCols, 0) FormContent.lblHeader(tCols).Text = Convert.ToString(ds.Tables(TableName).Columns.Item(tCols)) FormContent.lblHeader(tCols).Location = New Point(FormContent.TablePanel.Location.X, 10) FormContent.lblHeader(tCols).Visible = True FormContent.lblHeader(tCols).AutoSize = True Next FormContent.TablePanel.Location = New System.Drawing.Point(221, 46) FormContent.TablePanel.Name = "TablePanel" FormContent.TablePanel.RowCount = 2 Dim x As Integer = ds.Tables(TableName).Columns.Count Dim y As Integer = ds.Tables(TableName).Rows.Count ReDim FormContent.lblContent(x * y) Dim ctr As Integer = 0 For tRows = 0 To ds.Tables(TableName).Rows.Count - 1 For tCols = 0 To ds.Tables(TableName).Columns.Count - 1 FormContent.lblConten

      M Offline
      M Offline
      Mycroft Holmes
      wrote on last edited by
      #2

      I have only used the flowcontrol and in that case I created a user control for each set of data, placed all the management for the cotrol inside the user control and loaded 1 copy of the user control per record into the flowcontrol. That strategy may be relevant to the table control!

      Never underestimate the power of human stupidity RAH

      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