| View previous topic :: View next topic |
| Author |
Message |
Martijn Wenke General User

Joined: 23 Jan 2004 Posts: 10
|
Posted: Fri Feb 13, 2004 2:43 am Post subject: Reading & refreshing ListBox |
|
|
In Write I created a dialog wit a listbox ('profiles')
On the dialog there is a [delete] button to delete an item.
The 'click on [delete]' is processed by routine DeleteProfile (while the dialog is not closed)
DeleteProfile :
| Code: |
Sub DeleteProfile
...
id = 0
oProfileList = oProjectDialog.getControl("profiles")
...
sSQL = "SELECT * FROM personen WHERE profile = '" + oProfileList.GetSelectedItem + "'"
MsgBox(sSQL)
ResultSet = Statement.executeQuery(sSQL)
If Not IsNull(ResultSet) Then
' ******** Does record exist?
While ResultSet.next
id = ResultSet.getString(1)
Wend
Endif
...
' --> here I delete the record if id > 0
' --> here I have to delete the item in the list & refresh the list
...
End Sub
|
oProfileList.GetSelectedItem is returning a empty string. If I call oProfileList.GetSelectedItem after clicking on OK, the result is a valid listbox entry.
So:
1 - how to get the selected item during dialog activation?
2 - and how can I delete an item in DeleteProfile and refresh the list?
Regards,
Martijn |
|
| Back to top |
|
 |
dfrench Moderator

Joined: 03 Mar 2003 Posts: 1605 Location: Wellington, New Zealand
|
Posted: Sat Feb 14, 2004 9:55 am Post subject: |
|
|
| Quote: | | 1 - how to get the selected item during dialog activation? | I can't replicate your problem. My actions were
1. create a dialog (Dialog1) with a listbox (ListBox1) and button (CommandButton1)
2. create macro code | Code: | global oDialog1 as object
Sub Dialog1Show
DialogLibraries.LoadLibrary( "Standard" )
oDialog1 = CreateUnoDialog( DialogLibraries.Standard.Dialog1 )
oDialog1.Execute()
End Sub
Sub DeleteProfile
oProfileList = oDialog1.getControl("ListBox1") 'dialog control
sSQL = "SELECT * FROM personen WHERE profile = '" + oProfileList.GetSelectedItem + "'"
MsgBox(sSQL)
End Sub | 3. Assign DeleteProfile sub to buttonpressed event of commandbutton1
4. Show the dialog by executing the macro Dialog1Show from the document
5. Select an entry from the displayed list
6. Press the command button and SSql is displayed as expected...
| Quote: | | 2 - and how can I delete an item in DeleteProfile and refresh the list? |
Have a look at the example of Dialog in the StarOffice Programmer's Tutorial (5.6 Forms and Controls) this shows the use of listeners and callbacks. |
|
| Back to top |
|
 |
Martijn Wenke General User

Joined: 23 Jan 2004 Posts: 10
|
Posted: Mon Feb 16, 2004 6:30 am Post subject: Listbox problem fixed |
|
|
The Listbox problem is fixed.
I use the same construction as in your sample: a global dialog object.
I made the mistake to create the Dialog again in the click routine (so I was working with a copy).
Next problem to solve is the ListBox refreshing.
Regards,
Martijn |
|
| Back to top |
|
 |
|