数据网格标题文本对齐as3



我想改变数据网格标题文本从左到中对齐。

这是使用的

// sample code
var tf:TextFormat = new TextFormat(); 
tf.size = 15; 
tf.font = "Arial" ;
tf.color = 0x0000FF;
tf.align = "CENTER";
// also tried tf.align = TextFormatAlign.CENTER;

var room_name:DataGridColumn = new DataGridColumn("Room_Name"); 
room_name.headerText = "Room Name"; 

var minimum_chips:DataGridColumn = new DataGridColumn("Minimum_chips"); 
minimum_chips.headerText = "Minimum Chips"; 
dtgrid.setRendererStyle("textFormat", tf);

  dtgrid.setStyle("headerTextFormat",tf);
  dtgrid.columns = [room_name , minimum_chips];

更改文本格式的任何值都反映在标题文本中,期望对齐。我想设置对齐中心。谢谢。

如何改变css?

DataGrid
{
    headerStyleName:dataGridHeaderStyle;
}
.dataGridHeaderStyle
{
    textAlign:center;
    fontWeight:bold;
}

或者如果你想在as3定义样式,写下面的代码:

var newstyle:CSSStyleDeclaration = new CSSStyleDeclaration();
newstyle.setStyle("textAlign", "center");
newstyle.setStyle("fontWeight", "bold");
dtgrid.setStyle("headerStyleName", newstyle);

最新更新