| View previous topic :: View next topic |
| Author |
Message |
washington General User

Joined: 14 Jul 2003 Posts: 13 Location: Duisburg, Germany
|
Posted: Thu Aug 07, 2003 2:08 am Post subject: Fill listbox from another subroutine ?? |
|
|
Hello,
i want to fill a listbox with data from database.
That is in another subroutine as i call the frame.
If i want to call the subroutine Fill_ListBox with a button,
the listbox in the frame does not fill.
Sub Fill_ListBox
REM *** Connection to the Database opens before ***
Statement = Connection.createStatement()
ResultSet = Statement.executeQuery("select FIRST " & "30" &_
" fb_id from sicadi.a_druckanschrift where druckstatus = 1")
If Not IsNull(ResultSet) Then
While (ResultSet.next)
For i = 1 To 1
sMySQLString = ResultSet.getString(i)
oListBox = oDialog.getControl("FB_Liste1")
oListBox.addItem( sMySQLString, 1 )
Next i
Wend
End If
End Sub
If i use this code in the sub call-frame, the listbox is filled.
I hope, I articulated my problem understandably.
Thanks a lot.
Greetings
Carsten Klein |
|
| Back to top |
|
 |
openmind OOo Enthusiast


Joined: 28 Jun 2003 Posts: 106 Location: Switzerland
|
Posted: Fri Aug 08, 2003 2:51 am Post subject: |
|
|
Following code works on OOO1.1rc. In my opinion it should work on OOo1.x but i'm not sure. Try it out.
| Code: | Sub FillListbox
Dim writerDokument as Object
Dim docController as Object
Dim drawPage as Object
Dim listBox as Object
Dim listBoxView as Object
writerDokument = thisComponent
docController = writerDokument.CurrentController
drawPage = writerDokument.DrawPage
listBox = DrawPage.Forms.GetByName( "Standard" ).getByName( "listbox" )
listBoxView = docController.getControl( listBox )
listBoxView.addItem( "item" ,listBoxView.getItemCount() )
End Sub |
|
|
| Back to top |
|
 |
washington General User

Joined: 14 Jul 2003 Posts: 13 Location: Duisburg, Germany
|
Posted: Sun Aug 10, 2003 10:42 pm Post subject: Fill listbox from another subroutine ?? |
|
|
Hello,
when i try it out, i get the following exception at this point:
listBox = DrawPage.Forms.GetByName( "Standard" ).getByName( "listbox" )
Type: com.sun.star.container.NoSuchElementException
Greetings
Carsten |
|
| Back to top |
|
 |
openmind OOo Enthusiast


Joined: 28 Jun 2003 Posts: 106 Location: Switzerland
|
Posted: Mon Aug 11, 2003 12:31 am Post subject: Re: Fill listbox from another subroutine ?? |
|
|
| washington wrote: | Hello,
when i try it out, i get the following exception at this point:
listBox = DrawPage.Forms.GetByName( "Standard" ).getByName( "listbox" )
Type: com.sun.star.container.NoSuchElementException |
Sure. The Listbox is called ByName("listbox"). You have to adjust the name of the listbox in the code or in the properties dialog of the listbox. Doesn't matter which one you adjust but In the end they must be the same.
| Code: | listBox = DrawPage.Forms._
GetByName( "Standard" ).getByName( "myNameIsWashington" ) |
|
|
| Back to top |
|
 |
washington General User

Joined: 14 Jul 2003 Posts: 13 Location: Duisburg, Germany
|
Posted: Mon Aug 11, 2003 1:56 am Post subject: Fill listbox from another subroutine ?? |
|
|
Surely IŽd changed in:
listBox = DrawPage.Forms._
GetByName( "Standard" ).getByName( "FB_List1" )
As I defined before the lisbox. |
|
| Back to top |
|
 |
openmind OOo Enthusiast


Joined: 28 Jun 2003 Posts: 106 Location: Switzerland
|
Posted: Mon Aug 11, 2003 5:42 am Post subject: |
|
|
Sorry for not mention it: it should work if you adjusted the name of the form a n d the name of the control.
Did you made a new form or did you insert your controls in the 'standard'-Form which already existed?
To see which element is missing you can split the code in two lines:
| Code: | Dim form as Object
form = DrawPage.Forms.GetByName( "Standard" )
listBox = form.getByName( "listbox" ) |
When the error occured it shows you at which line the error is (form or listbox?). In the former example you can't distingush between missing the form or missing the conrtol with the information of error line.[/code] |
|
| Back to top |
|
 |
washington General User

Joined: 14 Jul 2003 Posts: 13 Location: Duisburg, Germany
|
Posted: Mon Aug 11, 2003 10:41 pm Post subject: Fill listbox from another subroutine ?? |
|
|
Hello,
I use the 'standard' - Form and the error is in the following line:
| Code: | | form = DrawPage.Forms.GetByName( "Standard" ) |
The module that's start at the begin of the program, opens as follows:
| Code: | REM *** fForDruck is the module which is called ***
oDialog = createUnoDialog(DialogLibraries.Standard.fForDruck) |
|
|
| Back to top |
|
 |
openmind OOo Enthusiast


Joined: 28 Jun 2003 Posts: 106 Location: Switzerland
|
Posted: Tue Aug 12, 2003 12:54 am Post subject: |
|
|
Now i see. We are talking from diffferent things. I'm talking about forms and your talking about dialogs; thats a difference
I pointed you in the wrong direction. Sorry about that.
| Code: | Global oDialog as Object
Sub openDialog
oDialog = createUnoDialog(DialogLibraries.Standard.fForDruck)
oDialog.execute()
End Sub
Sub anotherRoutine
oDialog.getControl( "FB_List1" )
' do what you want with your listbox
End Sub
Sub thirdSubroutine
oDialog.endExecute()
End Sub |
Deklar the dialog as a global variable to access it from any other subroutine you want.
I should read the posting more precise  |
|
| Back to top |
|
 |
washington General User

Joined: 14 Jul 2003 Posts: 13 Location: Duisburg, Germany
|
Posted: Tue Aug 12, 2003 1:19 am Post subject: Fill listbox from another subroutine ?? |
|
|
Sorry, if I expressed misleadingly.
That, what you had written had I already tried out, but the current dialog simply not filled.
My Code:
| Code: | sMySQLString = ResultSet.getString(i)
oListBox = oDialog.getControl("FB_List1")
oListBox.addItem( sMySQLString, 0 ) |
|
|
| Back to top |
|
 |
washington General User

Joined: 14 Jul 2003 Posts: 13 Location: Duisburg, Germany
|
Posted: Tue Aug 12, 2003 2:02 am Post subject: Fill listbox from another subroutine ?? |
|
|
Oh my god, I forgot to initialize the oDialog - variable as GLOBAL.
I'm so blind.
Thankyou very much, for your generous assistance.
Greetings
Carsten |
|
| Back to top |
|
 |
|