Re: Changing values in a list view column

new topic     » goto parent     » topic index » view thread      » older message » newer message

Jonas,
only the first column can be edited in this manner. This is because the
ListView control was originally designed by Microsoft to allow different
views of directory contents. The idea was that the first column would
contain the filename, and it would allow you to rename the file without
calling up a dialog box. You will note that when trying to change any other
attributes of a file from the MS_Explorer window, you have to call up the
Properties dialog.

Of course, people are now using the listview for all sorts of things it
wasn't originally intended for. However, MS still haven't enhanced it up
date any column - only the first one.

So, the ListView is not a good choice for a grid control.

I expect you might need to go low-level and create a window that has a set
of 'cells' that are really edit boxes or just child windows, set up as
children of the grid window. You would have to handle all the row/column
scrolling etc yourself. Good luck.

--------------
Derek
----- Original Message -----
From: "Jonas Temple" <jktemple at yhti.net>
To: "EUforum" <EUforum at topica.com>
Sent: Saturday, April 27, 2002 4:44 AM
Subject: Changing values in a list view column


>
> To anyone interested...
>
> The included code snippet lets you do in-place editing of a list view
> column's contents.  To change the contents, click ONCE on the first
> column of each list view item.  Wait a second and then an edit control
> should appear.  Type in some text and press Enter.  The column data is
> updated.  There is a button on the bottom that SHOULD start editing of a
> column but it doesn't work :(
>
> Anyway, has anyone else ever tried this?  Is there any way to change the
> contents of columns other than the first?  How do I force editing of
> another column/row with the LVM_EDITLABLE message?  I guess what I'm
> wondering is if you can, with a list view control, come up with a
> primitive grid control?
>
> Jonas
>
> Here is the code!
>
> include win32lib.ew
> without warning
> with trace
> atom void
> global constant MainWin = create(Window, "Test Editable List Views", 0,
> 0, 0, 500, 400, 0),
>                 lv = create(ListView, {"Column1","Column2","Column3"},
> MainWin, 10, 10, 400, 300,
>                             or_all({LVS_REPORT,LVS_EDITLABELS})),
>                 pb = create( PushButton, "Test", MainWin, 10, 350, 90,
> 30, 0)
>
> procedure MainWin_onEvent(atom event, atom wParam, atom lParam)
>     atom edit_ctl, iLength, buffer, id, msg
>     sequence text, selection
>     if event = WM_NOTIFY then
>         id = getId( fetch( lParam, NMHDR_hwndFrom ))
>         msg = fetch( lParam, NMHDR_code )
>         if id = lv and (msg = LVN_ENDLABELEDITW or msg =
> LVN_ENDLABELEDITA) then
>             edit_ctl = sendMessage(lv, LVM_GETEDITCONTROL, 0, 0)
>             if edit_ctl then
>                 iLength = w32Func( xSendMessage, { edit_ctl,
> WM_GETTEXTLENGTH, 0, 0 } )
>                 if iLength > 0 then
>                   iLength += 1
>                   buffer = acquire_mem(0, iLength )
>                   iLength = w32Func( xSendMessage, { edit_ctl,
> WM_GETTEXT, iLength, buffer } )
>                   text = peek( {buffer, iLength} )
>                   release_mem( buffer )
>                   selection = getLVSelected(lv)
>                   setLVItemText(lv, selection[1], 0, text)
>                 end if
>             end if
>         end if
>     end if
> end procedure
> onEvent[MainWin] = routine_id("MainWin_onEvent")
>
> procedure MainWin_onOpen()
>     atom index, mask, void
>     sequence data
> mask = or_all({LVS_EX_HEADERDRAGDROP,LVS_EX_GRIDLINES,
> LVS_EX_TRACKSELECT })
> void = sendMessage(lv, LVM_SETEXTENDEDLISTVIEWSTYLE, mask, mask)
>
>     for i = 1 to 3 do
>         data = {"Row" & sprintf("%d", i) & "Col1",
>                 "Row" & sprintf("%d", i) & "Col2",
>                 "Row" & sprintf("%d", i) & "Col3"}
>         index = addLVItem(lv, 0, data)
>     end for
> end procedure
> onOpen[MainWin] = routine_id("MainWin_onOpen")
>
> procedure pb_onClick()
>     sequence selection
>     atom void
>     selection = getLVSelected(lv)
>     void = sendMessage(lv, LVM_EDITLABEL, 1, 0)
> end procedure
> onClick[pb] = routine_id("pb_onClick")
>
>
> WinMain(MainWin, Normal)
>
>
>
>

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu