Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS General Discussion » How to dynamically change which column is sorted in the grid Collapse All
Subject Author Date
East Frontier Sep 23, 2005 - 1:42 AM

I want to use a combo box to specify which column of the CExtGridWnd I want to sort.


Currently, I can manually set which column to sort by just clicking on the column header.


How can I dynamically change the sorted column of the grid by changing the selection on the combo box?


 


Thanks in advance for your help.

Technical Support Sep 23, 2005 - 7:45 AM

The data sorting is performed by the CExtGridWnd::GridSortOrderSetup virtual method, which either sets new sorting rules or modifies the current rules. For example, the following code snippet sets ascending order for the first column:

CExtGridDataSortOrder gdsoColumns;

CExtGridDataSortOrder::ITEM_INFO _soii( 

    0, // sort first column

    true // true - ascending sort order, false - descending

    );

gdsoColumns.m_arrItems.Add( _soii );

 

m_wndGrid.GridSortOrderSetup(

    false, // true - sort colums, false - sort rows

    gdsoColumns,

    false,

    false, // invert sort order

    true

);