15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


in place editing in CListCtrl

Sumit Chawla -- schawla@csci.csc.com
Monday, July 22, 1996

Environment: Windows-NT 3.51/VISUAL C++ 4.0

I am creating a CListCtrl derived object with the							
LVS_REPORT | LVS_EDITLABELS styles. I want to be able to 
inplace edit columns of this control. 
I am using EditLabel() to begin the editing.
The problem is that the  edit control 
always appears on the 0th column irrespective of what
column I am editing. I can position it on the column I want
to by calling MoveWinow() but as soon as I start typing into
the edit control it moves back to 0th column.??


---------------------------------
Sumit Chawla
TRIS+ GUI Team
Computer Sciences Corporation
IL 61820
USA
Email: schawla@csci.csc.com



Gonzalo Isaza -- gonzaloi@microsoft.com
Wednesday, July 24, 1996

[Mini-digest: 3 responses]

This is the way the control is designed to work. You should not move the
edit control yourself.  In order to do what you want you need to
overimpose your own edit control over the column you want to edit and do
the work yourself.  This is easy to do.  Things to keep in mind:

 - Sett the right font for the edit control.  You can find the font by
calling CListCtrl::GetFont.
 - Subitems display the text shifted to the right the width of one space
character.  To find the right measure call pDC->GetTextExtent after you
have assigned the right font to the edit control.  This will be
important if you want the edit control to overlap perfectly over the
column you are editing.  You can get the location for the edit control
using CListCtrl::GetItemRect .

Good luck.

Gonzalo.

I speak for myself.  I do not speak for Microsoft.

>----------
>From: 	Sumit Chawla[SMTP:schawla@csci.csc.com]
>Sent: 	Monday, July 22, 1996 7:17 AM
>To: 	mfc list
>Subject: 	in place editing in CListCtrl
>
>Environment: Windows-NT 3.51/VISUAL C++ 4.0
>
>I am creating a CListCtrl derived object with the							
>LVS_REPORT | LVS_EDITLABELS styles. I want to be able to 
>inplace edit columns of this control. 
>I am using EditLabel() to begin the editing.
>The problem is that the  edit control 
>always appears on the 0th column irrespective of what
>column I am editing. I can position it on the column I want
>to by calling MoveWinow() but as soon as I start typing into
>the edit control it moves back to 0th column.??
>
>
>---------------------------------
>Sumit Chawla
>TRIS+ GUI Team
>Computer Sciences Corporation
>IL 61820
>USA
>Email: schawla@csci.csc.com
>
-----From: Roger Onslow/Newcastle/Computer Systems Australia/AU

That is correct -- edit label is *only* for the row label (ie column 0)
Other columns are not (strictly speaking) labels, just extra sub-items.
You are basically trying to *cheat* and Win95 ain't letting you!!

If you want to edit other columns, I suggest that you pop up
a simple dialog when you double click on a label which lets you
edit all the values for label and columns as edit boxes, etc.

Or perhaps include edit boxes for columns at the top to the
dialog, and update their contents as you select rows, and allow
the user to change values in the boxes and write back to list box
contents (either on kill focus, or changed or when user press a modify button 
etc)
Have a look at the Custom tab in File Properties in Word for editing
contents of a list box like this.

Alternatively, if you want to do some fiddling around, you can detect
a (double) click on a column, determine which column it is, create you
*own* edit box, position it over the column, all text entry, and when use
box looses focus, (if not escape) copy data into correct column position.

But this is really non-standard behaviour.

What you really want (by the sounds of it) is a grid control (like the
OCX provided with MSVC, I believe)

hope this helps

           /|\        Roger Onslow
      ____|_|.\       ============
    _/.........\Senior Software Engineer
   /CCC.SSS..A..\
  /CC..SS...A.A..\   Computer
 /.CC...SS..AAA...\       Systems
/\.CC....SSAA.AA../            Australia
\ \.CCCSSS.AA.AA_/
 \ \...........//      Ph: +61 49 577155
  \ \...._____//      Fax: +61 49 675554
   \ \__|_/\_//    RogerO@compsys.com.au
    \/_/  \//

-----From: Kostya Sebov 

Genuine listview implementation doesn't seem to support in-place editing
anywhere besides the 1st column items (in report view).

I did some "heavy-weight" MFC-based customizations of CListCtrl that allows
in-place editing on the whole grid but I'm absolutelly not satisfied with the
result. I didn't manage to make it reliable or elegant.

If your application really needs grid-based editing I'd recommend suing some
grid OCX or MFC class built from scratch (there is a lot of ads on this on the
Net).

--- 
Kostya Sebov. 
----------------------------------------------------------------------------
Tel: (38 044) 266-6387 | Fax: (38 044) 266-6195 | E-mail: sebov@is.kiev.ua



Felipe -- jordaof@moodys.com
Monday, July 29, 1996



Environment:  VC++ 4.0, NT 4.0b2

I'm also experiencing difficulties trying to get the in place editing.  I   
was trying to move the edit control because I couldn't figure out the way   
to call/override EditLabel().  Do I do this after I handle   
LVN_BEGINLABELEDIT or should I be doing this another way.  What I've done   
so far is figure out the column that was clicked, get that subitem text   
and then use a call to SetWindowText() (in the BeginLabelEdit handler) to   
put that in the edit control (which always appears at the 0th column).

Are there more specific intructions on how to go about getting my own   
edit control on the right column by means of EditLabel()?

thanks
Felipe

 ----------
From:  owner-mfc-l
Sent:  Wednesday, 24 July, 1996 11:25
To:  'mfc-l@netcom.com'
Subject:  RE: in place editing in CListCtrl

[Mini-digest: 3 responses]

This is the way the control is designed to work. You should not move the
edit control yourself.  In order to do what you want you need to
overimpose your own edit control over the column you want to edit and do
the work yourself.  This is easy to do.  Things to keep in mind:

 - Sett the right font for the edit control.  You can find the font by
calling CListCtrl::GetFont.
 - Subitems display the text shifted to the right the width of one space
character.  To find the right measure call pDC->GetTextExtent after you
have assigned the right font to the edit control.  This will be
important if you want the edit control to overlap perfectly over the
column you are editing.  You can get the location for the edit control
using CListCtrl::GetItemRect .

Good luck.

Gonzalo.




Gonzalo Isaza -- gonzaloi@microsoft.com
Thursday, August 01, 1996

Forget EditLabel or use it only for column 0, whatever is your choice.

You should create your own CEdit control to handle the editing.  Forget
about LVN_BEGINLABELEDIT for the subitems.  You must determine some
other way that the user needs to edit (click, doubleclick or your own
personal choice).  There is no LVN_BEGINLABELEDIT for  subitem columns
(LVS_REPORT is assumed, right?).  Your edit control should not be
visible at first. When the user wants to edit, find out the  rectangle
for the item.  Resize your own edit control considering the information
I gave before, Set the text for your edit control to be the same as the
subitem (with SetWindowText for example), move the edit control to
overlap the item in the column and finally make your edit control
visible.  Once the editing is done, get the text from the edit control,
transfer it to the subitem, and make your edit control invisible again.

Gonzalo
I speak for myself.  I don't speak for Microsoft

>----------
>From: 	Jordao, Felipe[SMTP:jordaof@moodys.com]
>Sent: 	Monday, July 29, 1996 6:45 AM
>To: 	'+ MFC List'
>Subject: 	RE: in place editing in CListCtrl
>
>
>
>Environment:  VC++ 4.0, NT 4.0b2
>
>I'm also experiencing difficulties trying to get the in place editing.  I was
>trying to move the edit control because I couldn't figure out the way to
>call/override EditLabel().  Do I do this after I handle LVN_BEGINLABELEDIT or
>should I be doing this another way.  What I've done so far is figure out the
>column that was clicked, get that subitem text and then use a call to
>SetWindowText() (in the BeginLabelEdit handler) to put that in the edit
>control (which always appears at the 0th column).
>
>Are there more specific intructions on how to go about getting my own edit
>control on the right column by means of EditLabel()?
>
>thanks
>Felipe
>
> ----------
>From:  owner-mfc-l
>Sent:  Wednesday, 24 July, 1996 11:25
>To:  'mfc-l@netcom.com'
>Subject:  RE: in place editing in CListCtrl
>
>[Mini-digest: 3 responses]
>
>This is the way the control is designed to work. You should not move the
>edit control yourself.  In order to do what you want you need to
>overimpose your own edit control over the column you want to edit and do
>the work yourself.  This is easy to do.  Things to keep in mind:
>
> - Sett the right font for the edit control.  You can find the font by
>calling CListCtrl::GetFont.
> - Subitems display the text shifted to the right the width of one space
>character.  To find the right measure call pDC->GetTextExtent after you
>have assigned the right font to the edit control.  This will be
>important if you want the edit control to overlap perfectly over the
>column you are editing.  You can get the location for the edit control
>using CListCtrl::GetItemRect .
>
>Good luck.
>
>Gonzalo.
>
>



Brian_Dormer@ftdetrck-ccmail.army.mil
Friday, August 02, 1996

     There was a recent (last 3-4 months) article in Microsoft Systems 
     Journal - that presented a class to do exactly this (CEditListBox or 
     something like that).  They have a website at:
     
     www.mfi.com/msj
     
     You can download the source for the articles there.
     
     bd
     


______________________________ Reply Separator _________________________________
Subject: RE: in place editing in CListCtrl
Author:  mfc-l@netcom.com at Internet-Mail
Date:    7/29/96 9:45 AM


     
     
Environment:  VC++ 4.0, NT 4.0b2
     
I'm also experiencing difficulties trying to get the in place editing.  I   
was trying to move the edit control because I couldn't figure out the way   
to call/override EditLabel().  Do I do this after I handle   
LVN_BEGINLABELEDIT or should I be doing this another way.  What I've done   
so far is figure out the column that was clicked, get that subitem text   
and then use a call to SetWindowText() (in the BeginLabelEdit handler) to   
put that in the edit control (which always appears at the 0th column).
     
Are there more specific intructions on how to go about getting my own   
edit control on the right column by means of EditLabel()?
     
thanks
Felipe
     




| Вернуться в корень Архива |