Changing Weblistbox visibility or tabpanel resets current row

When changing the visible-property of the weblistbox control from true to false and then back to true again, the listbox refreshes and moves to the top of the list. The same happens if you place the weblistbox on a panel and you change the panel. Or when you show and then hide a second webpage, for example to show the details of the selected row. It will be confusing when the user returns to the listbox and the selected row is no longer visible.

There is however a workaround using Javascript.

To hide, use:
lstWeblistbox1.ExecuteJavascript(“document.getElementById(’” + lstWeblistbox1.ControlID + "’).style.display=‘none’; )

To show, use:
lstWeblistbox1.ExecuteJavascript(“document.getElementById(’” + lstWeblistbox1.ControlID + "’).style.display=’’; )

Just a quick off-topic note that may save you some typing in the future…the jQuery library is a dependency of Xojo Web, so you can use that to knock off a few keystrokes. :wink:

To hide, use:

ExecuteJavascript( "$('#" + lstWeblistbox1.ControlID + "').css('display', 'none');" )

To show, use:

ExecuteJavascript( "$('#" + lstWeblistbox1.ControlID + "').css('display', '');" )