Combobox: problem with additem

Hello,
I have problem with “AddItem” but I don’t understand why :expressionless:

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

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

Yes :smiley: exactly, was the command “AddItems” deleted?
In this page, there is not “insertItemText”…
http://www.openoffice.org/api/docs/common/ref/com/sun/star/awt/XComboBox.html#addItem

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

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 :slight_smile:

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

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 :expressionless:

What about oCtrl.removeAllItems() ?

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

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 :slight_smile:

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

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.

OK thank you