this article was contributed by motty cohen.
download source code and demo project
this is a previous version of chris maunders mfc grid control (version 1.03) with a minor bug fix and several improvements.
first a bug fix: in some situations i have managed to edit cells in fixed column, so i added a line in oneditcell() event handler to prevent it:
if ((nrow < m_nfixedrows)||(ncol < m_nfixedcols)) return;
and the improvements:
m_arcoltypethis array holds the edit type for each column. this edit type can take one of these values:
there are more styles (gvet_combobox, gvet_checkbox) that are not implemented for now. (maybe someone would take the challenge to implement those styles before i do j).
int insertcolumn(lpctstr strheading, uint nformat = dt_center|dt_vcenter|dt_singleline, int ncolumn = -1, int ntype = gvet_noedit);
and i added the function:
bool setcolumntype(int ncol, int ntype);
virtual void filllistitems(int ncol, lparam cltlist);
to use the listbox cells attribute, you have to inherit your class from the cgridctrl
and override the function : filllistitems. this function is called before any inplace
listbox is opened in order to fill its items by addstring. you can set the
user-defined data for each listbox item. this data is attached to the grid items
user-defined data. (this is useful for lookup lists in the grid).
i would like to thank all the guys who contribute articles and code to this site and especially for zafir anjum and all the others who keeps this site so useful. i know i gain a lot of knowledge and save a lot of time by constantly visiting here.
last updated: 17 april 1998