To detect selected line just use form data sources.
Override active() method of the date source – it’s executed when a user switches to another record. The active record is in the automatic variable with same name as the data source.
Here is an example
public int active()
{
int ret;
ret = super();
if (ret)
{
element.InitActivityTree(AL0VendorActivityAreaView_ds, ActivityTreeAreaView, LogisticsAddressStateAreaView_ds.cursor().RecId); //This is the active record id
}
return ret;
}