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 Tech Support » Set Selection in CExtGridWnd by code Collapse All
Subject Author Date
Suhai Gyorgy Jul 26, 2006 - 4:08 AM

Dear Support,

I tried using SelectionSet to set selection in a CExtGridWnd. For testing purposes I put the following code at the end of CPageGrid::OnInitDialog() of your ProfUIS_Controls Sample (right before return TRUE;):

CRect rectCell;
m_wndGrid.GridCellRectsGet(0L, 3L, 0, 0, &rectCell);
m_wndGrid.SelectionSet(rectCell);
LONG nRowIndex = m_wndGrid.SelectionGetFirstRowInColumn(0L);

My problem is that nRowIndex gets to be -1, even though it should be 3L. Why is that?

Regards:
Chris

Dominic Tioseco Jan 6, 2020 - 10:20 PM

Hi,
Would you please give me an example on how to use CExtGridWnd::SelectionSet() ? If I have a 4x4 grid, how do I pro grammatically select the second row and first column?

Thanks,
Dominic

Technical Support Jul 26, 2006 - 7:32 AM

The source code in your message is not correct. The CExtGridWnd::GridCellRectsGet() method allows you to get the location of a grid cell and the location of any of its parts. The location is specified in pixels of grid window’s client area. The CExtGridWnd::GridCellRectsGet() method returns false if the grid cell is outside the visible range of cells. In this case it is not possible to compute the cell location and you should always analyze the returned boolean value. The CExtGridWnd::SelectionSet() method allows you to change the selection in the grid window. The selection region in the grid is implemented as an array of rectangles. Each rectangle contains zero-based numbers of columns and rows. This selection region based on rectangles is used in the grid window regardless of if the grid is full row, full column or custom range selection oriented. So, the rectangle you specified in the parameters of the CExtGridWnd::SelectionSet() method should contain row/column numbers -- not pixels.

Suhai Gyorgy Jul 26, 2006 - 8:06 AM

Thank you very much! The Help wasn’t very clear on this method and no Sample contained call of CExtGridWnd::SelectionSet(), which could clear it up. I’ll try it this way then.