Combo Box in AX Dynamics

Here is my requirement.

I have a form with data like Student Id, Name Gender and date of Joining. Also, I have a Combo Box with 2 values: Male and Female.

I want that whenever I select Male in ComboBox only records with Gender as male should get displayed and vice versa.

Kindly share the code also.

You only need add a range on the query of your datasource and on modified method of your combobox add the value for the range.