Ask Your Question
0

combobox: problem with additem

asked 2018-01-13 10:33:34 +0100

Fede gravatar image

updated 2018-01-13 10:34:01 +0100

Hello, I have problem with "AddItem" but I don't understand why :-|

Sub StartDialog

Dim n As Integer
Dim i As Integer
Dim oData As Variant
Dim oCtrl 
Dim sVal as String

oSheet = ThisComponent.GetSheets().GetbyName("Prova_1")
oForm = oSheet.DrawPage.Forms.getByIndex(0)  
oCtrl = oForm.getByName("ComboId")


oCtrl.Text = "Select text input format from the list."

' Read the data list from cell range into a variant array '
oData =ThisComponent.GetSheets().GetbyName("ML").getCellRangeByName("G5:JS5").DataArray

n = ThisComponent.GetSheets().GetbyName("ML").getCellRangeByName("G5:JS5").GetColumns.GetCount

print n

For i = 0 to n

    oCtrl.addItem(oData(i),i)
Next i

End Sub

Can You help me?

Thank you

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
1

answered 2018-01-13 11:29:25 +0100

JohnSUN gravatar image

updated 2018-01-13 11:29:45 +0100

It seams to me that you lookup something like this:

Sub StartDialog
Dim i As Integer
Dim oData As Variant, oRow As Variant
Dim oCtrl As Variant
    oSheet = ThisComponent.GetSheets().GetbyName("Prova_1")
    oForm = oSheet.DrawPage.Forms.getByIndex(0)  
    oCtrl = oForm.getByName("ComboId")
Rem Read the data list from cell range into a variant array 
    oData =ThisComponent.GetSheets().GetbyName("ML").getCellRangeByName("G5:JS5").DataArray
    oRow = oData(0)
    For i = LBound(oRow) to UBound(oRow)
        oCtrl.insertItemText (i, oRow(i))
    Next i
    oCtrl.Text = "Select text input format from the list."
End Sub
edit flag offensive delete link more

Comments

Yes :D exactly, was the command "AddItems" deleted? In this page, there is not "insertItemText".... http://www.openoffice.org/api/docs/co...

Can you explain me the command "oRow = oData(0)" Thank you so much:)

Fede gravatar imageFede ( 2018-01-13 11:40:22 +0100 )edit

The addItem wasn't "deleted", and is functional. The problem is you use of "oData(i)" which gives an array, where a string is expected.

And now you refer to another (also present) addItems, that is different beast :)

Mike Kaganski gravatar imageMike Kaganski ( 2018-01-13 11:44:33 +0100 )edit

Property .DataArray or method .getDataArray() return array of arrays - set of rows which of them is array of cells. Try to see value oData in debugger - it can helps to understand the structure of this array

JohnSUN gravatar imageJohnSUN ( 2018-01-13 13:22:13 +0100 )edit

If I want to delete the items in the combobox?

I have had these instruction

nCount = oCtrl.getItemCount()
    oCtrl.removeItems(0,nCount)

but I obtain only error :-|

Fede gravatar imageFede ( 2018-01-15 14:51:55 +0100 )edit

What about oCtrl.removeAllItems() ?

JohnSUN gravatar imageJohnSUN ( 2018-01-15 17:53:48 +0100 )edit

Yes, It run:D but where you find the correct functions? I find only old commands .....

Fede gravatar imageFede ( 2018-01-16 08:07:10 +0100 )edit

Even if you don't have an XRay or MRI extensions for inspection of objects, you still may look at the object in debugger's watch, and see its supported services and Types (which is the list of UNO interfaces, with description of all methods right there).

Btw: but I obtain only error :-| is not a good description. What specific error was that? At least I couldn't find a ":-|" error in the source code :)

Mike Kaganski gravatar imageMike Kaganski ( 2018-01-16 08:21:10 +0100 )edit

@Kaganski: Ok I will be more clear:). Any question: the XRay and MRI extension may be download from internet? What is the debugger watch?

Fede gravatar imageFede ( 2018-01-16 08:29:06 +0100 )edit

Try this or this . Unfortunately the format of this resource does not involve long discussions - here you can ask a question and get an answer (sometimes two or three answers). Please try some specialized forum.

JohnSUN gravatar imageJohnSUN ( 2018-01-16 09:46:08 +0100 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2018-01-13 10:33:34 +0100

Seen: 16 times

Last updated: 2 days ago