How to use a gridcontrol in a dialog, as kind of multicolumn listbox

In the GUI editing mode of dialogs there is an icon that says ‘table control’ when hoovering over it. Once inserted in the dialog the name GridControl is suggested. From the naming I expect that a kind of MainForm_Grid can be created, that can be populated with columns and rows either from Calc or Base.
That would be very suited to simulate a kind of multicolumn listbox, in case more information/sorting is desirable to make a selection.
However I don’t see options to insert columns in the control, leave alone rows, nor can I find documentation for this control in help - wiki - guides - ask. In the API LibreOffice: com::sun::star::awt Module Reference , there is no UnoControlxxxxModel entry that suggest the object I’m looking for, so a macro construction is blocked as well.

Any information is welcome, also that this concerns a future expansion?


Yes, that is in fact a Grid control. Within a dialog there are no data aware controls. All data movement, in or out, must be done through macro code by the user.

For more information on this icon and more on the Grid control, please see my answer, links, and comments in this post → Macro insert data into table control @dialog


Here are some links to documentation:

UNO Grid Control

GridColumn Service Reference

UnoControlGridModel Service Reference

DefaultGridDataModel.idl File Reference

As for future enhancements, as this control (not as icon) has been around for some time, not certain of any enhancements to be applied.

OK @Ratslinger, that’s what I was looking for, thanks. I have seen your BASIC example, and inspired by that, did transform it to Python code.

The uploaded file dialog.odt contains, embedded, your BASIC code and Python code for a dialog with GridControl. The macros are the first members of Tools in the menubar
I will also make a link to overhere in the post concerning the listener question you dealed with a week ago.

An updated dialog.odt file, now enabling sorting of colums, also while maintaining the already selected rows in the correct way. In basic and python

dialog.odt (30.1 KB)

1 Like

You could also have a look at German Base Handbuch, p. 565 ff. and the attached database Beispiel_Dialoge inside this *.zip. But: I have all written in German …