I am experimenting with the weblist box controller and the mapviewer control in XOJO. Trying to decide if I want to upgrade from release 2012.r2 enterprise.
I am trying to read a pre filled list box with sample addresses and then add location to the map viewer. I keep getting an error that the item does not exist when I put the following code in the action event on a web button
dim i as Integer
for i = 0 to listbox1.listcount -1 //< this is the line that the error shows up is there something different with the web list box. I cannot find the listcount method in the language reference. is this still supported.
if i = 0 then
textfield1.text = str(listbox1.cell(listbox1.listindex,0))
location.address = TextField1.Text
Mapviewer1.AddLocation(location) // adda pin to map
end if
so I found out that Listcount is really rowcount
So that fixed my first problem, now I am getting an out of bounds error trying to load the contents of the listbox1 to a textfield1
dim i as Integer
for i = 0 to listbox1.rowcount -1
if i = 0 then
textfield1.text = str(listbox1.cell(listbox1.listindex,0)) // out of bounds error not sure why…list box has 4 rows and is only one column
location.address = TextField1.Text
Mapviewer1.AddLocation(location) // add a pin to map
end if
next
Tim’s right in your code you are trying to assign text to a textbox that doesn’t exist yet because as you don’t have a row selected when the code is called.
So a fix for that is to check if you do have a row selected… just throw in a line of code to check
Ok thanks for the info, I added a line to say of code to add to show that (i) is selected and a line to check to see if listbox is -1.
I have also added through the control for items in the list box so the row count of 3 (I think). The list box is a single column and no header
the check for listbox being greater than -1 doesn’t recognize the items in the control.
(environment is
a) XOJO 4.1
b) web page
c) push button
d) Mapviewer
e) listbox
The code below is in the push button action method.
I know this is simple but, I am not seeing it…
dim location as new WebMapLocation
dim i as Integer
if listbox1.listindex>-1 then
for i = 0 to listbox1.rowcount -1
listbox1.Selected(i)=true
//for i = 0 to listbox1.listcount -1
if i = 0 then
textfield1.text = str(listbox1.cell(listbox1.listindex,-1))
location.address = TextField1.Text
Mapviewer1.AddLocation(location) // adda pin to map
end if
next
Given that code, you should see the textfield holding the value of the selected row only. Is that what you see? Is it what you intended? Please tell us what you expect to see and what you actually do see. It will be much more helpful than just throwing code on the screen. I can tell you that this code looks weird, but that doesn’t help unless I know what you really intended to happen.