1

I am developing an OpenOffice Writer template that can be used to fill in reports for a child-care centre.

There are some standard outcomes, comprising long sentences, and I want the user to be able to select the appropriate sentence from a combo box. I have entered the sentences into a table in Openoffice Base database, which is then connected to a series of combo boxes in a Writer template. However, when the user choose an option that contains a very long sentence, only the text up to the length of the combo box is visible.

What I want to do is have the selected value of the combo-box wrap over several lines when selected so that all the (very long) text appears in the selected box when the user chooses a long sentence from the combo.

I have been looking through the properties of the combo box control, but have yet to identify one that will allow the selected value in the combo box to word-wrap (so that I could make the combo-box several lines in height such that the entire sentence would fit into the box).

Any pointers on how I could do this would be much appreciated.

thanks,

David.

David
  • 515
  • 8
  • 17

2 Answers2

1

Thanks Jim K, that was helpful. In the end, what I wound up doing was creating a textbox which I named "selectedOutcomeATextBox" immediately below my combo box which was named "OutcomeCombo".

I then attached the following macro code to the textModified event associated with the "selectedOutcomeATextBox":

Sub UpdateOutcomeA

    Dim Doc As Object
    Dim Form As Object
    Dim Ctl As Object
    Dim newCtl as Object

    Doc = ThisComponent
    Form = Doc.DrawPage.Forms.GetByIndex(0)
    Ctl = Form.getByName("OutcomeCombo")
    newCtl = Form.getByName("selectedOutcomeATextBox")

    newCtl.Text = Ctl.Text

End Sub

I also set the "Printable" property of the "OutcomeCombo" to "No", so that when the document prints, the combo box itself does not appear on the printed page, but the "selectedOutcomeATextBox" textbox which has had its value set by the macro when I choose a value from the combo box does appear with the desired text. I also set the "TextType" property of the selectedOutcomeATextBox" text box to "Multi-Line", so that extra long text will wrap to the next line, thereby showing the very long strings that are stored there.

Thanks heaps Jim K.

cheers,

David Buddrige

David
  • 515
  • 8
  • 17
  • Yes, that's basically what I had in mind, except my idea was to use a list control instead of a combo box. The difference between the two is that combo boxes allow entry of any value. In this case, the user could enter any value in the text box, so the extra functionality that a combo box gives seems redundant. Technically, a [combo box](https://en.wikipedia.org/wiki/Combo_box) is simply a combination of a list control and a text box. – Jim K Mar 07 '16 at 20:22
  • Feel free to accept your own answer instead, as it is much more complete than mine, and it is generally the best of the possibilities. If you decide to change it to a list control, you can edit your answer. – Jim K Mar 07 '16 at 20:35
0

Apparently combo boxes do not have the MultiLine attribute. The question was asked a few years ago here but was not solved.

One alternative that requires some macro programming is to use a single multi-line text field and then make a scroll bar button that changes the choice. Instead of a scroll bar, two buttons could be used to change the choice (Previous / Next), or even a list box control. Using a list box control in this way would have the advantage that they could see all the choices at once, like a combo box.

Another approach is to break up each sentence and display the parts across several lines of a list box. Then when one line is clicked, all the lines of a sentence are selected at once, using an event listener for the list box. This could be shown in addition to an ordinary editable multi-line text box, in case none of the answers in the list are wanted.

One more idea: Radio buttons can have multiple lines, so dynamically show radio buttons, one for each sentence. A dialog window could be displayed to hold the radio buttons. The result of the dialog would be used to fill the multi-line text field.

Or you could just live with the truncated sentences. Maybe it would help to make the control a little wider, or abbreviate the sentences.

Jim K
  • 12,824
  • 2
  • 22
  • 51