Page 1 of 1

Creating a grid of controls

Posted: Mon Apr 09, 2018 2:23 pm
by guest
(copied from the old forum)

In LB 4.04 and 4.51 it is not possible to create a grid of child controls using a loop; every control must be created individually, and with a large grid that can mean a lot of code! In LBB it is straightforward using MAPHANDLE:

Code: Select all

  for row = 1 to 13
    statictext #win.st, str$(row), 95, 18 + row*20, 18, 20
    textbox #win.tb1, 115, 12 + row*20, 350, 25
    textbox #win.tb2, 461, 12 + row*20, 40, 25
    stylebits #win.tb2, _ES_RIGHT, 0, 0, 0
    maphandle #win.st, "#win.statictext";row
    maphandle #win.tb1, "#win.leftbox";row
    maphandle #win.tb2, "#win.rightbox";row
  next
  WindowWidth = 600
  open "Looped controls" for window as #win
  wait
The code creates this window:

Image

Richard.