Archive for August 4th, 2007

04
Aug

Filtering an XMLListCollection using the filterFunction property and regular expressions

Here is another handy little tip that you see all over the web, how do I filter a data grid (or other list-based control) based on a user’s input? Or more specificially, how to I limit the items that show in a list based on what a user types.

Since I already created a simple XML document of Countries/States, I thought I’d create a basic form that lets a user type in the first few characters of a state name and have the DataGrid filter its results. You’ll also notice that I had to do some not-so-tricky E4X filtering to extract only the American state names.

Full code after the jump.

Continue reading ‘Filtering an XMLListCollection using the filterFunction property and regular expressions’

04
Aug

Creating two related ComboBoxes

This is a semi-common problem. You have two (or more) ComboBox controls and you want the options in second combo box to change based on the selected item in the first combo box. Or in a real world case, you have a list of countries and a list of provinces/states/regions in that country. When the user changes the value in the country combo box to “Canada”, you would only want to display a list of Canadian provinces/territories in the second combo box. Although if the user selected USA in the country combo box, you would only want to show the American states/regions.

Anyways, enough jibber-jabber, lets see this in action.

Full code after the jump.

Continue reading ‘Creating two related ComboBoxes’