The GroupExpandingCollapsing Event is not beeing fired when expanding/collapsing group by double click. It only works when using the little arrow button
Had to create a workaround by wrapping the ObjectListView class with my own WndProc:
public EventHandler<GroupExpandingCollapsingEventArgs> GroupExpandingCollapsing2;
...
// well.. i dunno if theres a better msg to catch
if (m.Msg == WM_LBUTTONDBLCLK)
{
// this just gives me the listview control
//Control ctrl = Control.FromHandle(m.HWnd);
//Point pt = PointToClient(Cursor.Position);
Point pt = new Point(Native.LOWORD(m.LParam), Native.HIWORD(m.LParam));
//Console.WriteLine($"------------------ {pt.X} / {pt.Y}");
// loop through each group
foreach(OLVGroup grp in this.OLVGroups)
{
// get group header rect
RECT rectHeader = new RECT();
rectHeader.top = LVGGR_HEADER;
SendMessage(m.HWnd, LVM_GETGROUPRECT, grp.GroupId, ref rectHeader);
Rectangle rect = new Rectangle(rectHeader.left, rectHeader.top, rectHeader.right - rectHeader.left, rectHeader.bottom - rectHeader.top);
// and check if the clicked point is inside rect
if (rect.Contains(pt))
{ // found the group header!!
// the wnd msg is received after collapsing/expanding
// so grp.Collapsed is true when the grp has been collapsed
// do something...
GroupExpandingCollapsingEventArgs args = new GroupExpandingCollapsingEventArgs(grp);
GroupExpandingCollapsing2?.Invoke(this, args);
if (args.Canceled) return;
}
}
return;
}
Last edit: Yvonne Pautz 2022-12-07
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Had to create a workaround by wrapping the ObjectListView class with my own WndProc:
Last edit: Yvonne Pautz 2022-12-07