// detect if this listviewitem needs to support GridItem pattern static private bool IsImplementingGrid(IntPtr hwnd) { // in the detail mode, GridItem will be implemented on the subitem // and not item if (WindowsListView.IsDetailMode(hwnd)) { return(false); } return(WindowsListView.IsListMode(hwnd) || WindowsListView.ListViewAutoArrange(hwnd)); }
// Scroll the specified headerItem horizontally into view. internal void ScrollIntoView(HeaderItem headerItem) { // Check if the parent is a ListView IntPtr hwndParent = NativeMethodsSetLastError.GetAncestor(_hwnd, NativeMethods.GA_PARENT); if (hwndParent != IntPtr.Zero) { if (Misc.GetClassName(hwndParent).IndexOf("SysListView32", StringComparison.Ordinal) >= 0) { // Determine the number of pixels or columns to scroll horizontally. int pixels = 0; int columns = 0; // Get first and last visible header items. HeaderItem firstVisibleHeaderItem; HeaderItem lastVisibleHeaderItem; GetVisibleHeaderItemRange(out firstVisibleHeaderItem, out lastVisibleHeaderItem); if (firstVisibleHeaderItem != null && firstVisibleHeaderItem._item > headerItem._item) { // Scroll backward. pixels = (int)(headerItem.BoundingRectangle.Left - firstVisibleHeaderItem.BoundingRectangle.Left); columns = headerItem._item - firstVisibleHeaderItem._item; } else if (lastVisibleHeaderItem != null && headerItem._item > lastVisibleHeaderItem._item) { // Scroll forward. pixels = (int)(headerItem.BoundingRectangle.Left - lastVisibleHeaderItem.BoundingRectangle.Left); columns = headerItem._item - lastVisibleHeaderItem._item; } int horizontalScrollAmount = 0; if (WindowsListView.IsListMode(hwndParent)) { // In list mode, LVM_SCROLL uses a column count. horizontalScrollAmount = columns; } else if (WindowsListView.IsDetailMode(hwndParent)) { // In details mode, LVM_SCROLL uses a pixel count. horizontalScrollAmount = pixels; } if (horizontalScrollAmount != 0) { Misc.ProxySendMessage(hwndParent, NativeMethods.LVM_SCROLL, new IntPtr(horizontalScrollAmount), IntPtr.Zero); } } } }