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 » SetItemData in ExtGridWnd? Collapse All
Subject Author Date
Dave M Jun 28, 2005 - 2:33 PM

In the standard MFC CListCtrl class, there’s a method called SetItemData that allows the programmer to assign any application-specific value to a particular row. Is there something like this in the CExtGridWnd class?

Technical Support Jun 29, 2005 - 5:25 AM

The CExtGridWnd control works with a number of CExtGridCell objects organized into a two dimensional matrix of columns and rows. If you need to assign custom data to a row, create a cell class that contains application-specific data and use it in grid columns that can be either data columns or header columns. It is handy to use a zero-width header column in your case:

wndGrid.OuterColumnCountLeftSet( 1L, false );
wndGrid.OuterColumnWidthSet( true, 0L, 0 );
You need to insert your cell class into each header cell when you insert a new row:
CExtGridCell * pCellHeaderAtLeft =
   wndGrid.GridCellGetOuterAtLeft(
      0L,
      nRowNo,
      RUNTIME_CLASS(
         C_YOUR_GridCellHeader
   )
);
ASSERT_VALID( pCellHeaderAtLeft );
Your C_YOUR_GridCellHeader grid cell class should be derived from CExtGridCellHeader. Please do not forget to specify the IMPLEMENT_ExtGridCell_Clone( C_YOUR_GridCellHeader, CExtGridCellHeader ) macro in the class declaration.

Dave M Jun 29, 2005 - 7:37 AM

Thanks, that was very helpful, and should work out well!

On another note, how do you format your code blocks in posts with the courier font and the gray background? I’d like to do that in the future to make my posts more readable.

Thanks again!

Technical Support Jun 29, 2005 - 8:34 AM

You can easily post code blocks using these HTML tags:
<code><pre>
Your code (courier, gray background)
</pre></code>

Please note that in case of IE you need to select View HTML source check box. We also recommend you preview your message before posting by clicking the Preview button.