Possibly Obvious - Dynamic control Creation

Okay. I either need more caffine this morning, or I’m just plain having a blonde moment. I’m trying to dynamically create a bunch of custom container controls when a page loads that is data driven. Everything things seems to run, no errors. However, I see no controls in the web page.

Here’s my code:

[code] Dim sql As String
Dim mdb as new MySQLCommunityServer
Dim data As RecordSet
Dim catName as String
Dim xRow as RowContainer // custom class with image controls and such for a video library interface
Dim xTop as integer = rowNewest.Top + rowNewest.Height + 15 // For establishing the top of each creates row down the page.

//Database initialization
mDB.Host = Session.mDBHost
mDB.UserName = Session.mDBUserName
mDB.Password = Session.mDBPassword
mDB.DatabaseName = Session.mDBDatabaseName
mDB.Port = Session.mDBPort
mDB.MultiThreaded = False

if mdb.Connect then

sql = "SELECT * FROM tblCategories"

data = mDB.SQLSelect(sql)

While Not data.EOF
  
  catName = data.Field("CategoryName").StringValue
  
  xRow = new RowContainer
  
  xRow.Top = xTop
  xRow.Left = rowNewest.left
  xRow.Width = rowNewest.Width
  xRow.LockTop = true
  
  xRow.loadCategory(catName)  //Code that populates row container
  xRow.Visible = true
  
  xTop = xRow.Height + 15
  
  data.MoveNext
  
Wend

end if

if data <> Nil then
data.Close
end if

mDB.Close[/code]

A big pat on the back to whoever can straighten me out. THX!

Containers are added to the page using EmbedWithin:

https://documentation.xojo.com/index.php/WebContainer.EmbedWithin

Big Pat On Back

Thanks. I figured it was something straight forward. :slight_smile:

Controls are displaying great. However, even though I have many generate down the webpage, the browser has no scroll bar, so I can’t get down to see all of them. What is the best way to get the browser to display a scroll bar?

I notice that if I resize the browser upward and into the static controls, the scroll appears. Perhaps the browser is not aware of the new dynamic controls?

Perhaps not. You could try calling Self.Show on the page to get it to refresh or you could embed your containers into a new container that will get its own scroll bar.

Set the WebPage.MinHeight property high enough to encompass the controls you’ve added.

You are ‘da man’ Greg! Thanks for the help.