组合框文本格式通过AS3组合、文本、格式

2023-09-08 12:49:36 作者:我向来孤僻成性却念你好深

我开发AIR应用程序,我需要改变显示在下拉列表中,以及在下拉框中的正文文本的字体大小。我的组合框的大小是相当大的,但它显示的文本是非常小的。我试着使用setStyle方法传递一个TextFormat进去,如:

I am developing an AIR application and I need to change the font size of the text that is displayed in the dropDown List as well as the main text on the comboBox. My ComboBox is quite big in size but the text displayed in it is very small. I tried using the setStyle method by passing a TextFormat into it like :

cmbEmployee.setStyle(参考textFormat,txtform);

cmbEmployee.setStyle("textFormat", txtform);

但没有奏效。虽然同样的方法可以很好地处理一个文本字段。

but it didn't work. Although the same method works well with a TextField.

有人可以帮忙吗?

推荐答案

好了好组合框是一个容器,其中包含的文本字段和下拉列表。所以你不能直接应用本身,而需要将其应用到组合框内部的特定元素的组合框的使用setStyle。

Alright well the ComboBox is a container which contains the TextField and the DropDown List. So you can't directly apply the setStyle on ComboBox itself rather you need to apply it to the specific element inside the ComboBox.

//Text Formats that needs to be applied on your comboBox
var txtformat:TextFormat = new TextFormat(); 
    txtformat.size = 30;   //Lets just increase the size of fonts   

//Increase the main TextField's font size of your ComboBox
yourComboBox.textField.setStyle("textFormat", txtformat);

//Increase the font size of dropDownList items
yourComboBox.dropdown.setRendererStyle("textFormat", txtformat);

试试吧!

 
精彩推荐
图片推荐