Re: [api-dev] How set a Default Value to a FormControl ListBox

2009-01-05 Thread Frank Schönheit - Sun Microsystems Germany
Hello Fernand,

 but even manual entered list entries the famous  button  gives an 
 ugly beep as respons, is this a bug or are am i doging something wrong ?

hmmm, no problem here with using this  Sounds like, well, at least a
oddity of your installation/environment/version.

Ciao
Frank

-- 
- Frank Schönheit, Software Engineer frank.schoenh...@sun.com -
- Sun Microsystems  http://www.sun.com/staroffice -
- OpenOffice.org Base   http://dba.openoffice.org -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

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



Re: [api-dev] How set a Default Value to a FormControl ListBox

2008-12-18 Thread Jason Stephenson

You could also try something like this:

Sub DoThing
Dim Form As Object
Dim ListBox As Object
Dim Controller As Object
Dim ListBoxControlModel As Object

' Get controller for the current document
Controller = ThisComponent.getCurrentController()

' Assuming first or only form
Form = ThisComponent.Drawpage.Forms.getByIndex(0)
ListBox = Form.getByName(ListBoxName) 'I prefer getByName().
ListBoxControlModel = Controller.getControl(ListBox)

ListBoxControlModel.selectItem(ItemTextToSelect, True)
' If it is a database/data form, you will want to do the following.
' Otherwise, you might not need the next line.
ListBox.commit()
End Sub



I don't know if the above is quicker or easier than what Ariel 
suggested, but its the way that I typically do it in database forms when 
i need to select a particular item in a list box, usually based on some 
other control value.


Also, in a database, all new records show the empty selection for the 
list box, because the data value in the control is not bound to 
anything, yet. Thus, you need the ListBox.commit() line above to tell 
the form to update the data for this field. If you don't do the 
commit(), this field will be null when you save the record.


HtH,
Jason

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



Re: [api-dev] How set a Default Value to a FormControl ListBox

2008-12-18 Thread Fernand Vanrie

Thanks, for the exelent explainations,

but even manual entered list entries the famous  button  gives an 
ugly beep as respons, is this a bug or are am i doging something wrong ?


Frank Schönheit - Sun Microsystems Germany wrote:

Hi Fernand,

  

again the secrets are in the control :-)

oform = thisComponent.drawpage.forms.getbyname( Ingave)
omodel = oform.CbxTaal
oControl = ThisComponent.CurrentController.getControl( omodel)
'
ocontrol.selectitem(N, true)



This indeed changes the selection at the control only, not at the model,
which means that when you save the document, the current selection in
the listbox will not persist (since it's only the model which is saved).

For your concrete problem of setting the selection programmatically, I
am not sure if you really want to set the *default selection* (which is
applied, for instance, when you call .reset at the control model), or
the *current selection* (which is what you see immediately in the control.

For the current selection,
http://api.openoffice.org/docs/common/ref/com/sun/star/awt/UnoControlListBoxModel.html#SelectedItems
is what you need to change.

  Dim nSelection(1) as Integer
  nSelection(0) = ...
  nSelection(1) = ...
  oControlModel.SelectedItems = nSelection()

The values in the array need to be the 0-based indexes of the entries
you want to select.

For the default selection (which upon setting it is used as current
selection, too, though you can change the current selection without
changing the default selection),
http://api.openoffice.org/docs/common/ref/com/sun/star/form/component/ListBox.html#DefaultSelection
works out, the very same way as SelectedItems.

  

still have the question how to set a Default value with the GUI !!



The *current selection* cannot be changed via the UI, for ... hmm, for
no apparent reasons (except historical ones). What you can change is the
*default selectio*, which, as said above, also changes the current
selection when changed itself. For this, just press the ... button in
the Default selection line in the property browser, but make sure
beforehand the list box actually has list entries.

Ciao
Frank

  



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



[api-dev] How set a Default Value to a FormControl ListBox

2008-12-17 Thread Fernand Vanrie

Hallo all,
First I treed to set with the GUI a  a Default value into a FormControl 
ListBox but no sucses, the opening ListBox stays empty and the entered 
value disapered ?


then i tried  the same  me thing using the API no sucses...;

my best gues was

oform.CbxTaal.setPropertyvalue(Selecteditems,N) N is one of the 
list entries
but here i have a error  i need no string but a type short ??  


how do i produce this type short  in Basic ?

Wath i basicly want to do is to have control over the item  (who is part 
of the list entries ) who is showed when opening a form.


Thanks for any hints

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



Re: [api-dev] How set a Default Value to a FormControl ListBox

2008-12-17 Thread Jason Stephenson

You could also try something like this:

Sub DoThing
Dim Form As Object
Dim ListBox As Object
Dim Controller As Object
Dim ListBoxControlModel As Object

' Get controller for the current document
Controller = ThisComponent.getCurrentController()

' Assuming first or only form
Form = ThisComponent.Drawpage.Forms.getByIndex(0)
ListBox = Form.getByName(ListBoxName) 'I prefer getByName().
ListBoxControlModel = Controller.getControl(ListBox)

ListBoxControlModel.selectItem(ItemTextToSelect, True)
' If it is a database/data form, you will want to do the following.
' Otherwise, you might not need the next line.
ListBox.commit()
End Sub



I don't know if the above is quicker or easier than what Ariel 
suggested, but its the way that I typically do it in database forms when 
i need to select a particular item in a list box, usually based on some 
other control value.


Also, in a database, all new records show the empty selection for the 
list box, because the data value in the control is not bound to 
anything, yet. Thus, you need the ListBox.commit() line above to tell 
the form to update the data for this field. If you don't do the 
commit(), this field will be null when you save the record.


HtH,
Jason



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