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 » change color in the grid Collapse All
Subject Author Date
Eike Loch Nov 12, 2004 - 8:17 AM

I would like change the color for the current selection (cell, row, ... )


and highlighted row / column.

Technical Support Nov 12, 2004 - 9:00 AM

You should create a class derived from CExtGridWnd and override the OnSiwGetSysColor virtual method like this:

COLORREF CMyGridWnd::OnSiwGetSysColor( int nIndex ) const
{
    if( nIndex == COLOR_HIGHLIGHTTEXT )
        return RGB(255,255,255); // selected text
    if( nIndex == COLOR_HIGHLIGHT )
        return RGB(255,0,0); // selected background
    return CExtGridWnd::OnSiwGetSysColor( nIndex );
}
The grid control uses the system color indexes to get all colors. But it calls the OnSiwGetSysColor virtual method instead of ::GetSysColor() (Win32 API). So, this code changes the selected text and background colors to white and red.

Another way to change cell colors is to completely repaint the cell in your custom-defined cell class.

Eike Loch Nov 12, 2004 - 10:07 AM

Thank you for your help,


I can not found the value for the parameter ’nIndex’ to manipulate the color for the row / column, which  highlight is enabled with the following flags:


__EGBS_EX_SI_HIGHLIGHT_COLUMNS
__EGBS_EX_SO_HIGHLIGHT_COLUMNS
__EGBS_EX_SI_HIGHLIGHT_ROWS
__EGBS_EX_SO_HIGHLIGHT_ROWS


__EGBS_EX_FI_HIGHLIGHT_COLUMNS
__EGBS_EX_FO_HIGHLIGHT_COLUMNS
__EGBS_EX_FI_HIGHLIGHT_ROWS
__EGBS_EX_FO_HIGHLIGHT_ROWS


 


 

Technical Support Nov 16, 2004 - 5:20 AM

The styles listed in your message are affected all rows and/or columns. If you want some particular row/column to be constantly (not depending on mouse hover, selected and focused cells), you need to override the grid/cell background painting code.