Click here to Skip to main content
14,028,769 members
Click here to Skip to main content
Add your own
alternative version


62 bookmarked
Posted 19 Aug 2001

Editable Table Control

, 19 Aug 2001
Rate this:
Please Sign up or sign in to vote.
An editable combo list control
<!-- Article image -->

Sample Image - editable_list.jpg

<!-- Add the rest of your HTML here -->


I had to implement some kind of list representation of a certain product-sell table (Product | Price | ProductID | Amount ). So, I decided to use ListCtrl for that matter. Basically, ListCtrl is fun to play with. One of the styles supported by ListCtrl is called report-view, which is used here. ListCtrl also allow editable entries as one of its styles. Unfortunately, when dealing with report-view, editing is applied only to the first column‘s elements.

My Solution

The solution was to create an Edit window on-demand, on top of the according cell-entry. Then, when done editing, a notification message is sent to parent ListCtrl. Thinking this idea is simple enough, I have also perfected it to create ComboBox on demand for certain cells to narrow the input options ( Such as Product field, which is out of the predefined list of elements ).


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Israel Israel
Nir Shilon -
B.Sc. in Mathematics & Computer Science of Tel-Aviv University.
I have worked for the past 2 years in DSPG as a R&D software engineer.
As part of Debugger/Simulator team ( Myself, Anna & Yair).
I basically taught myself MFC and other Win32 programming stuff.

You may also be interested in...


Comments and Discussions

GeneralMy vote of 2 Pin
China_NewComer18-Nov-13 5:49
memberChina_NewComer18-Nov-13 5:49 
QuestionScroll bar is black before clicking it Pin
bfm8923-Jun-13 16:28
memberbfm8923-Jun-13 16:28 
AnswerRe: Scroll bar is black before clicking it Pin
VincyChan25-May-15 15:07
professionalVincyChan25-May-15 15:07 
Questionedit other columns Pin
peoria12330-Apr-13 5:38
memberpeoria12330-Apr-13 5:38 
AnswerRe: edit other columns Pin
wy73722-May-13 12:22
memberwy73722-May-13 12:22 
GeneralMy vote of 5 Pin
frankagra29-Nov-11 11:29
memberfrankagra29-Nov-11 11:29 
QuestionHow to do sorting Pin
chevu6-Jul-09 19:21
memberchevu6-Jul-09 19:21 
QuestionCBS_DROPDOWN err Pin
bala_potty25-Apr-07 4:30
memberbala_potty25-Apr-07 4:30 
AnswerRe: CBS_DROPDOWN err Pin
Rolf Kristensen9-Sep-08 0:34
memberRolf Kristensen9-Sep-08 0:34 
GeneralRe: CBS_DROPDOWN err Pin
bala_potty15-Sep-08 20:17
memberbala_potty15-Sep-08 20:17 
GeneralThank you very much!!!! Pin
luoky20-Nov-06 23:23
memberluoky20-Nov-06 23:23 
GeneralI found a bug. Pin
rotaerc4-Jan-05 15:32
memberrotaerc4-Jan-05 15:32 
GeneralShort lists, no scoll bars, autoset drop down height Pin
Jordan Walters21-Sep-04 10:59
memberJordan Walters21-Sep-04 10:59 
If you have a very short list to display in the drop - say only 2 items - then the presence of the horizontal scroll at the bottom tends to obscure much of the fist item and all of the second item. Of course one could use the vertical scroller to scroll up and down between the items, but have you seen the size of the scroll buttons?

My proposal is that if there are not so many items in, say less than 10, then set the style as....

if(lstItems.GetCount() < 10)

And then one can use the autosizing function (which must be provided by oneself) to adjust the heoight of the combobox to show all items in the list....
<code> if(lstItems.GetCount() < 10)

where the function <code>CDialogHelpers::SetComboBoxDropDownHeight()</code> is implemented as follows.

void CDialogHelpers::SetComboBoxDropDownHeight(CComboBox *box, UINT nLinesToDisplay /* = -1 */)

ASSERT(IsWindow(*box)); // Window must exist or SetWindowPos won't work

if(nLinesToDisplay == -1)
nLinesToDisplay = box->GetCount();

CRect cbSize; // current size of combo box
int Height; // new height for drop-down portion of combo box

Height = box->GetItemHeight(-1); // start with size of the edit-box portion
Height += box->GetItemHeight(0) * (nLinesToDisplay + 1); // add height of lines of text

// Note: The use of SM_CYEDGE assumes that we're using Windows '95
// Now add on the height of the border of the edit box
Height += GetSystemMetrics(SM_CYEDGE) * 2; // top & bottom edges

// The height of the border of the drop-down box
Height += GetSystemMetrics(SM_CYEDGE) * 2; // top & bottom edges

// now set the size of the window
box->SetWindowPos(NULL, // not relative to any other windows
0, 0, // TopLeft corner doesn't change
cbSize.right, Height, // existing width, new height
SWP_NOMOVE | SWP_NOZORDER // don't move box or change z-ordering.

Excuse the use of the magic number 10 above, this would be replaced with a <code>#define</code> or <code>const</code> of course.

Hope this minor improvements helps any others out there who are frustrated by short lists appearing too small.

Generalquestion about ListCtrl EditBox and ComboBox Pin
alla_hpl27-Jan-04 3:22
memberalla_hpl27-Jan-04 3:22 
QuestionHow to use Editable List Control in CFrameView WIndow Pin
T R Raghavendra6-Dec-03 2:28
sussT R Raghavendra6-Dec-03 2:28 
GeneralProblem with scrolling Pin
Cabbi21-Apr-03 21:08
memberCabbi21-Apr-03 21:08 
GeneralRe: Problem with scrolling Pin
raba1621-Oct-03 5:53
memberraba1621-Oct-03 5:53 
GeneralRe: Problem with scrolling Pin
tom.schultz29-Mar-05 19:15
membertom.schultz29-Mar-05 19:15 
GeneralRe: Problem with scrolling Pin
wireman24-Jun-05 12:14
memberwireman24-Jun-05 12:14 
QuestionHow to suppress a combo box when uses Checboxes? Pin
yummi28-Jan-03 7:43
memberyummi28-Jan-03 7:43 
GeneralAuthor's response to supid Pin
shilonir24-Aug-01 1:41
membershilonir24-Aug-01 1:41 
GeneralWhen in Dialog the easier way Pin
22-Aug-01 2:49
suss22-Aug-01 2:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web06 | 2.8.190419.4 | Last Updated 20 Aug 2001
Article Copyright 2001 by shilonir
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid