Friday, April 24, 2009

How to traverse multiple selected lines in a grid control by using X++ code in Microsoft Axapta

This post describes how to use X++ code to traverse multiple selected lines in a grid control in Microsoft Business Solutions - Axapta. Do this when multiple rows of the information in the grid control contain the information which is required to perform the required request.
For example, you can use the following code in the click event of the button if you want to traverse two selected lines when the second row and the fourth row are highlighted in a grid control.

void clicked()
{
CustTable ct;
;
//ct is set to the forms data source and using a cursor goes through each record selected in the grid.
for (ct = DataSource1_ds.getFirst(true) ? DataSource1_ds.getFirst(true): DataSource1_ds.cursor(); ct;ct=DataSource1_ds.getNext())
{
print ct.AccountNum," ",ct.Name;
}
super();
}

No comments: