edit subitem cells in tadvlistview

 
I'm trying to allow editing of select cells in a TAdvListview said cells being subItems - the listview style is vsReport and I have several items worth of data populating it.
 
I have ReadOnly false, Rowselect False,  SubItemSelect True, SubItemEdit True, and in the CanEditCell event I have set Allow = True for all events for testing purposes.
 
And, nothing happens when I click on a cell and the CanEditCell event doesn't even fire.
 
What am I missing.
 
 
Darrel Christenson
 

 
Some additional information - I'm using Delphi 7 under Windows 7 64-bit Home Premium and the version of the advlistview I'm using is  1.6.5.1.
 
I've gotten the cell editing to kick in a few different ways by calling StartEdit from various events - it seems to work as in the cell in question is editable but there's some repainting going on under the hood and every time it seems some random cell on the same row always goes blank.  When I'm done with the edit as in leave the cell or control all the blank cells come back.
 
 
drc  :)
 

Same problem here with a much more recent version 1.7.1.0 of TAdvListView. The only difference in my case is that it's always column 0 which gets blank, meaning the item caption itself is not rendered if subediting is active.


I had a look at advlistv.pas and found code which handles LVN_BEGINLABELEDIT and registers a custom WNDPROC implemented by EditSubclassProc. It seems to me that subediting is implemented by "simply" moving the default edit input provided by Windows or TListView to the position of the column needed for the concrete subitem and afterwards the text of the sub item is inserted manually into the edit and retrieved afterwards. There's even the following line which saves the item's caption:


FItemCaption := GetTextAtColRow(0, FItemIndex);


In LVN_ENDLABELEDIT the text gets reset afterwards.

This looks like it's by design that the item caption is not rendered during subitem edits? Because in a default behavior the input for the new caption would be above the caption and thefere it's text wouldn't need to be rendered. Of course this is a problem if the input gets moved like it seems currently...

I tried some hours now using the CustomDraw and AdvancedCustomDraw callbacks and while I could influence what gets drawn, e.g. by simply changing the color within the callbacks, I have no clue how could access the item caption and get that to render always or render it manually or whatever.

Is there any workaround or fix available? Do I really need to replace the component with something other, some grid or such?

I have retested this with a default TAdvListView on the form and the following code:


procedure TForm4.FormShow(Sender: TObject);
begin
  advlistview1.TestFill(4,10);
  advlistview1.SubItemEdit := true;
  AdvListView1.SubItemSelect := true;
  AdvListView1.Enabled := true;
  AdvListView1.OwnerDraw := true;
end;

and this allows to edit subitems.

Editing SubItems works for me as well and did in the end for the original poster... But what is with the caption of the item, which is column 0 in vsReport? Is it shown properly if you edit a sub item? It is not in my case and wasn't when I tested in a clean project with a fresh AdvListView without any of my code.



https://picload.org/view/wlllggr/image001.png.html

I tested with another clean project again and it seems that activating "OwnerDraw" itself is the necessary bit: If deactivated the rendering looks better, but the caption is missing. If activated, the rendering lokks a bit more old school, but the caption is visible now!


I guess I focussed to much on implementing something in the other Draw*-callbacks yesterday and didn't ever try with that setting enabled.

Thanks!

The default drawing in a TListView doesn't support subitem selection drawing unfortunately, so it is only possible when doing custom drawing.

Make sense of course. Would be really cool if there was some mechanism to automatically activate OwnerDraw if SubItemEdit gets selected... But I guess such dependencies are not possible in the IDE?

Yes, that is a good tip to preset OwnerDraw when SubItemEdit is needed. We have extended the component for this and the next update will handle it this way.

Thanks!