База Libreoffice: выпадающий список продолжает заменять значение на 0

2965
Gabriel A. Zorrilla

У меня есть ComboBox, который загружает список стран, каждый раз, когда я выбираю один элемент, а затем фокусируюсь на другом объекте формы, он сбрасывается до 0. Этот ComboBox связан со значением Integer в главной таблице (он хранит индекс, а не Строка страны).

Какого черта я делаю не так?

0

1 ответ на вопрос

2
CatShoes

If I understand you correctly, you want a ComboBox that displays a list of country names and stores some sort of country code. You can use a ComboBox to display and store a field, but not to display one field and store another. Unlike the ListBox control, the ComboBox does not have a Bound Field property, which is required to use two fields. The Bound Field property determines what field is stored in your target table.

enter image description here

You need to use a ListBox control to get this functionality. The ListBox control should give you a wizard. First select the table the you want to display data from.

enter image description here

Then select the field you want to display.

enter image description here

Lastly, select the field you want to store the value to (left-side list) and the field you want to get the value from (right-side list). NOTE: In this example, I am only using one table. So I have the same options in both the left-side and right-side lists. Normally, you would pull this data from another table to be displayed and stored in the current - usually as some sort of foreign key relationship.

enter image description here

Then we need to make the ListBox act like a ComboBox, that is, make the ListBox have a dropdown menu. Right-click the ListBox and go to Control. Set the DropDown property to Yes. Set the LineCount to however many items you want displayed without needing to scroll (I like 5, personally). Lastly, set the Height to something more like what a Text field would be.

enter image description here enter image description here

Reference: http://user.services.openoffice.org/en/forum/viewtopic.php?p=164740#p164740