Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Hello,

From the start, I don't have an answer to your 'release mouse button to close dialog'. Have tried a few things without success.

Filling a list box in a dialog is easy:

DialogLibraries.LoadLibrary("Standard")
myDlg = CreateUnoDialog(DialogLibraries.Standard.YOUR_DIALOG)
lbField = myDlg.getControl("YOUR_LISTBOX")
lbField.addItem("LB Item One",0)
lbField.addItem("LB Item Two",1)
lbField.addItem("LB Item Three",2)

The two items you are entering using addItem are the verbiage itself (your cell content) and the second item is its position in the list. So retrieve the cell data and insert into list box.

You mention getting data from DB but I hesitate because of your comment. Twice it mentions MSQL (Hughes Technology) and once MYSQL ( seems more likely). You can use a macro to connect to a DB. Here is a connection to MySQL:

Dim oParms(1) as new com.sun.star.beans.PropertyValue 
oParms(0).Name = "user" 
oParms(0).Value = "root" 
oParms(1).Name = "password" 
oParms(1).Value =PASSWORD_HERE
oManager = CreateUnoService("com.sun.star.sdbc.DriverManager")
sURL = "sdbc:mysql:jdbc:localhost:3306/DATABASE_NAME"
oConnection = oManager.getConnectionWithInfo(sURL, oParms())
sSQL = "Select YOUR_FIELD(S) FROM YOUR_TABLE"
oStmt = oConnection.createStatement
oResult = oStmt.executeQuery(sSQL)

With that you use oConnection to submit SQL then process the result set. Not sure this is the best idea as each time you run it would need to read the DB for the data. It seems the cells are better.

Hello,

From the start, I don't have an answer to your 'release mouse button to close dialog'. Have tried a few things without success.

Filling a list box in a dialog is easy:

DialogLibraries.LoadLibrary("Standard")
myDlg = CreateUnoDialog(DialogLibraries.Standard.YOUR_DIALOG)
lbField = myDlg.getControl("YOUR_LISTBOX")
lbField.addItem("LB Item One",0)
lbField.addItem("LB Item Two",1)
lbField.addItem("LB Item Three",2)

The two items you are entering using addItem are the verbiage itself (your cell content) and the second item is its position in the list. So retrieve the cell data and insert into list box.

You mention getting data from DB but I hesitate because of your comment. Twice it mentions MSQL (Hughes Technology) and once MYSQL ( seems more likely). You can use a macro to connect to a DB. Here is a connection to MySQL:

Dim oParms(1) as new com.sun.star.beans.PropertyValue 
oParms(0).Name = "user" 
oParms(0).Value = "root" 
oParms(1).Name = "password" 
oParms(1).Value =PASSWORD_HERE
oManager = CreateUnoService("com.sun.star.sdbc.DriverManager")
sURL = "sdbc:mysql:jdbc:localhost:3306/DATABASE_NAME"
oConnection = oManager.getConnectionWithInfo(sURL, oParms())
sSQL = "Select YOUR_FIELD(S) FROM YOUR_TABLE"
oStmt = oConnection.createStatement
oResult = oStmt.executeQuery(sSQL)

With that that, you use oConnection to submit SQL then process the result set. Not sure this is the Could run separately when document opens & store data in a global variable. A lot depends upon your knowledge of macros. Dealing with the cells may be best idea as each time you run it would need to read the DB for the data. It seems the cells are better.

you.