Creating controls on the fly

It’s possible to create controls at runtime. This can be useful if you want to display some information temporarily without affecting the current form. The control gets created completely through code, which is certainly not as nice as having the IDE do it for you, especially with more complex objects.

In this example, we’ll create a div object. Div is one of the simplest elements that lies underneath NS Basic/App Studio objects. In fact, the HTMLView control is actually just a simple div.

Here’s the code:

  Dim newdiv
  newdiv = document.createElement("div")
  newdiv.setAttribute("id", "myNewControl") = "absolute" = "200px" = "40px" = "55px" = "200px" = "white" = "1px solid #000";

Now we can set its value just like we would an HTMLview:

  myNewControl.innerHTML="My new control"

To get rid of the control, do the following:


The CreateDiv sample is included starting with NS Basic/App Studio 1.1.3.

Edited 3/28/16 – fixed some errors in code