Ask Your Question

getByIndex; how find index of form field

asked 2020-09-24 18:18:32 +0200

Marigold gravatar image

updated 2020-09-24 18:20:50 +0200

I would like to use oField = oForm.getByIndex(indexNumber) method instead oField = oForm.getByName("fieldName"). But I can't find index number of element in my form.

Does anyone know how to find out index number?


edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2020-09-24 20:40:35 +0200

Lupp gravatar image

I don't think a FormControl would know its own index, and I have no idea in what way the information should actually be useful. Please tell us.
In what way would you identify the FormControl you want to know the index of?

Sub findControlIndexInFormForSelectedControlShape()
REM Assume a control (in fact the hosting shape) is selected in design mode.
sh = ThisComponent.CurrentSelection(0)
fc = sh.Control
fo = fc.Parent
u = fo.Count - 1
For j = 0 To u
  j_fc = fo(j)
  If equalUnoObjects(j_fc, fc) Then Exit For
Next j
Print "This time the selected FormControl had the index " & j
REM I don't know if there is an assertion concerning the stability of index assignment.
End Sub
edit flag offensive delete link more


I thought naively index of field is uniqe value of field. But wrong. It's just ordinal number. Why it would be useful? If the index is unique and unchangeable, if from some reason you must change name of form field, methods they use that field, remain usable.

Marigold gravatar imageMarigold ( 2020-09-26 11:21:01 +0200 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2020-09-24 18:18:32 +0200

Seen: 32 times

Last updated: Sep 24