mfc grid control with drop down lists


this article was contributed by motty cohen.

 download source code and demo project


this is a previous version of chris maunder’s 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:

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 it’s items by addstring. you can set the user-defined data for each listbox item. this data is attached to the grid item’s 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