Professional UI Solutions
Site Map   /  Register


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 » CExtGridWnd Collapse All
Subject Author Date
Roberto Manes Mar 4, 2008 - 7:53 AM

Could you tell me how to put in evidence one row of the grid ? In other words I would like to emulate the click of the mouse onto the grid.

Technical Support Mar 8, 2008 - 11:23 AM

Actually the row highlighting changing is implemented by default. When you press the Up key the selection moves to the previous row. When you press the Down key the selection moves to the next row. So it is unclear what behavior you are trying to implement. Would you clarify your issue with some screenshots and/or test project?

Roberto Manes Mar 6, 2008 - 7:23 AM

I understand that English is not my primary language but if I want to change the focus of the selected row( in a sigle row selection model) simply by clicking the arrow keys how can I do it ? My question seems really simple and I can’t understand how to use the virtual methods you suggested according to the solution of my problem.
So very simple
1. Click down arrow key I need the focus to be moved to the next row
2. Click up arrow key I need the focus to be moved to the previous row

Technical Support Mar 5, 2008 - 1:18 PM

Your code tries to track keyboard events for catching selection modification. This is principally incorrect because mouse events can also affect to both focus and selection in the grid window. Besides, in the multiple row/column selection model both mouse and keyboard events can be with or without shift and control keys pressed what makes selection behaving differently. And more, if the subtractive selection model is applied, then the mouse clicks with the control and, optionally, shift keys pressed will invert the selection in some region of cells. So, you need the following virtual methods:

      virtual void OnGbwSelectionChanged();
      virtual bool OnGbwFocusChanging(
            const POINT & ptOldFocus,
            const POINT & ptNewFocus,
            bool & bEnsureVisibleColumn,
            bool & bEnsureVisibleRow,
            bool & bResetSelectionToFocus,
            bool & bRedraw
      virtual void OnGbwFocusChanged(
            const POINT & ptOldFocus,
            const POINT & ptNewFocus
You can also override or use the following methods:
      virtual CPoint FocusSet(
            const POINT & ptNewFocus,
            bool bEnsureVisibleColumn = true,
            bool bEnsureVisibleRow = true,
            bool bResetSelectionToFocus = true,
            bool bRedraw = true,
            bool * p_bCanceled = NULL
      virtual bool SelectionGetForCell(
            LONG nColNo,
            LONG nRowNo
            ) const;
      virtual bool SelectionRemoveAt(
            INT nAreaNumber,
            bool bRedraw = true
      virtual bool SelectionSetAt(
            INT nAreaNumber,
            const RECT & rcNewSelection,
            bool bRedraw = true
      virtual bool SelectionInsertAt(
            INT nAreaNumber,
            const RECT & rcNewSelection,
            bool bRedraw = true
      virtual bool SelectionSet(
            const RECT & rcNewSelection,
            bool bReplaceOldAreas = true,
            bool bReplaceLastArea = false,
            bool bRedraw = true

Roberto Manes Mar 5, 2008 - 11:19 AM

The matter is the following : I have a grid with some rows and some columns. I click onto a row to select it entirely. When I click the left mouse button I see the complete row highligted with the background colored in blue and the two black arrows at the edges of the grid. Then I press the arrow keys up or down to move me to the previous or to the next row. When I do this I catch the message int the OnGbwAnalyzeCellKeyEvent() method and I like to do the following
1. I want to know the new selected item (with the SelectionGetFirstRowInColumn() method I know this)
2. then I know what arrow has been pressed so I would like to Highligh the new selected Item, that is, I wish to emulate the same behaviour like if I clicked with the left mouse button onto the previous/next row.
Actually if I use the SelectionGetPrevRowInColumn() method or the SelectionGetNextRowInColumn() method the last selected item remains highlighted without the black arrows at the edges, the new item is selected properly but when I go over a certain row I get a debug assert failure message line ExtGridWnd.cpp line 6229 (I’m running ProfUIS260 library full version)

Here is the code I wrote to catch the arrow keys

bool CUIProductsGridWnd::OnGbwAnalyzeCellKeyEvent(
        bool bKeyDownEvent, // true - key-down event, false - key-up event
        UINT nChar, // virtual key code
        UINT nRepCnt, // key-down/key-up press count
        UINT nFlags // key-down/key-up event flags
    CExtGridWnd::OnGbwAnalyzeCellKeyEvent(bKeyDownEvent, nChar, nRepCnt, nFlags);
    if( nRepCnt != 1 ) return false;

    if( !bKeyDownEvent ) return false;
    int nItemSelected;
    nItemSelected = SelectionGetFirstRowInColumn(0);

    if( nChar == VK_DOWN ) {
        SelectionGetNextRowInColumn(nItemSelected, 0);
        GetParent()->SendMessage(WM_ITEM_CHANGED, (WPARAM)(nItemSelected+1));
    if( nChar == VK_UP ) {
        SelectionGetPrevRowInColumn(nItemSelected, 0);

    if( nChar == VK_DELETE ) {
        ;// GetParent()->SendMessage(WM_ITEM_DELETE, ,(WPARAM)(nItemSelected));

    return true;

Technical Support Mar 5, 2008 - 10:54 AM

We think we need to discuss some details of your task. If you want to highlight some rows/columns/cell ranges, you can specify custom cell text/background colors using the CExtGridCell::BackColorSet() and/or CExtGridCell::TextColorSet() methods.

Roberto Manes Mar 5, 2008 - 6:49 AM

Yes but if I wish to highlight a certain row by means the row index how can I do it?

Technical Support Mar 5, 2008 - 3:56 AM

You should invoke the CExtGridBaseWnd::OnGbwAnalyzeCellMouseClickEvent() method.