# Determining text size on UIComponents

**URL:** <https://forum.kirupa.com/t/determining-text-size-on-uicomponents/291570>\
**Category:** flash\
**Created:** [July 1, 2009, 4:31pm UTC](https://forum.kirupa.com/t/determining-text-size-on-uicomponents/291570 "2009-07-01T16:31:32Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![AKirk](https://avatars.discourse-cdn.com/v4/letter/a/3be4f8/32.png) [@AKirk](https://forum.kirupa.com/u/AKirk)\
**Post date:** [July 1, 2009, 4:31pm UTC](https://forum.kirupa.com/t/determining-text-size-on-uicomponents/291570/1 "2009-07-01T16:31:32Z")

</div>

I want to know how wide a particular String would be if it were displayed in a List or DataGrid so that I can set the component’s width sufficient to accommodate my String.

In Flex there is a handy method UIComponent.measureText(text:[String):[URL=“http://www.kirupa.com/forum/…/…/flash/text/TextLineMetrics.html”]TextLineMetrics.](http://www.kirupa.com/forum/../../String.html)

However there seems to be nothing comparable in the Flash UI components.

It doesn’t even seem possible to determine what TextFormat is governing a UIComponent: calling getStyle(“textFormat”) on a List or DataGrid instance returns null.

Is there any reliable way to discover what TextFormat currently applies in a List or DataGrid?

Thanks  
Andy
