If the control gets an arrow key for instance, it should cancel editing and return the last key it encountered back to the grid via the GVN_ENDLABELEDIT notification message. Your editing object should handle mouse keys in a way that allows the user to navigate between cells while editing.Your editing control should stop editing when it loses input focus. The control will receive the row and column to be edited, the dimensions and location of the in-place edit control, the style of control to create, the original text in the cell plus the initial character that caused editing to commence (or VK_LBUTTON if the mouse was clicked on the current cell).There are a number of things to be aware of when creating such CWnd derived Edit classes: In Edit I create a CWnd derived class that will perform the actual editing - in this case my CInPlaceList from previous versions of the grid. You can find this class in the GridCellCombo.* files. The first step is to derive a new class from CGridCell - I call it CGridCellCombo - and override Edit (which initiates editing) and EndEdit (which stops editing). It's not the greatest - but it does demonstrate how to replace the default editing. I'm using the In-Place list that I used in previous versions. A new cell typeĬhanging the way cells are edited is simply a matter of deriving a new grid cell class from CGridCellBase (or derivatives such as CGridCell). With the new structure in the 2.X versions of CGridCtrl it's now a lot simpler. Previous methods of achieving this required that a new CGridCtrl derived class be created. For some this was a little too involved, so I've created a demo project that shows how to replace the default editing with a simple combo box. Ken Bertelson has taken this to the extreme, with his Grid Tree control. Since I posted my MFC grid control I've had a lot of requests asking how to use other methods of editing cells in the grid. Download full grid demo (v2.20) - 201.5 KB.Download full grid demo (v2.20, no executable) - 148.6 KB.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |