ComboBox FXML default value

前端 未结 3 1985
隐瞒了意图╮
隐瞒了意图╮ 2021-02-04 04:20

How can I set a default value in a ComboBox using FXML?



        
3条回答
  •  旧时难觅i
    2021-02-04 04:48

    I don't think it's possible in the FXML. You will need to do it in the initialization of the component, in the controller, for example using the following line cbo_Bacteriologie_Aesculine.getSelectionModel().setSelectedIndex(1); for selecting the element Bezig.

    But if you find a way to do it in FXML, I am interested.

    EDIT : It is possible in FXML. You can see it in Guedolino's answer (https://stackoverflow.com/a/14436371/1344424), which should become the right answer to this question.

提交回复
热议问题