Bonjour,

xavier roguiez a écrit :
> Bonjour
>> A partir de l'exemple suivant :
>>
>> http://www.oooforum.org/forum/viewtopic.phtml?t=55472&highlight=com+sun+star+form+component+combobox
>>
>>
>> tu devrais arriver à quelque chose ;-)
> C'est nickel, il me manquait le passage de la forme et la combobox.
> 
> Autre question : est il possible de renvoyer dans la cellule liée la
> position de l'item sélectionné dans le menu déroulant ?
> 

> Bon week end
> xavier

Pour retrouver l'index de l'item, voici une idée :

sub selectedComboItem

dim oSheet as object, oDrawPage as object, oCombo as object
dim i as integer
dim sLinkedCell as string
dim aCurrentValue as variant, aListeValues() as variant

oSheet = ThisComponent.CurrentController.ActiveSheet
oDrawPage = oSheet.DrawPage
sLinkedCell = oSheet.getCellRangeByName( "A5" ).String

oCombo = oDrawPage.Forms.getByName( "Standard" ).getByName( "ComboBox" )

aCurrentValue = oCombo.CurrentValue
aListeValues() = oCombo.StringItemList

for i = LBound( aListeValues() ) to UBound( aListeValues() )
 if aCurrentValue = aListeValues(i) then
  msgbox "L'index de l'item est le " & i+1
  exit for
 endif
next

end sub

Pour l'indiquer dans la cellule liée, tu pourrais faire comme cela :

oSheet.getCellRangeByName( "A5" ).String = aCurrentValue & " " & i+1

Francois Gatto


---------------------------------------------------------------------
To unsubscribe, e-mail: prog-unsubscr...@fr.openoffice.org
For additional commands, e-mail: prog-h...@fr.openoffice.org

Répondre à