ListView Scroll

chrisliando

Newcomer
Joined
Feb 17, 2008
Messages
6
I use Visual C++ and .Net 2.0.



I have 2 listViews, lv1 and lv2. All in Details View.



If I use the MouseWheel to scroll / use the listView scrollbar to scroll the content (Horizontally or Vertically) on either lv1 or lv2 then the other will synchronized (scroll at the same time).



How to do that since the listView does not have any Scroll related event?



I have successfully Scroll both listView but I must use Buttons, button1 for scrollup and button2 for scrolldown and they only scroll vertically like this:



[DllImport("user32.dll")]
static bool ShowScrollBar(System::IntPtr hWnd, int wBar, bool bShow);

[DllImport("user32.dll")]
static bool EnableScrollBar(System::IntPtr hWnd, UInt32 wSBflags, UInt32 wArrows);

[DllImport("user32.dll")]
static IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, UIntPtr wParam, IntPtr lParam);

private: static int const SB_VERT = 1;
private: static int const ESB_DISABLE_BOTH = 0x3;
private: static int const ESB_ENABLE_BOTH = 0x0;
private: static int const WM_VSCROLL = 0x115;



private: System::Void Results_Load(System::Object^ sender, System::EventArgs^ e) {
EnableScrollBar(this->lvSource->Handle, Convert::ToUInt32(SB_VERT), ESB_DISABLE_BOTH);
EnableScrollBar(this->lvDestination->Handle, Convert::ToUInt32(SB_VERT), ESB_DISABLE_BOTH);
}


private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
SendMessage(this->lvSource->Handle, Convert::ToUInt32(WM_VSCROLL), System::UIntPtr(Convert::ToUInt64(ScrollEventType::SmallDecrement)), System::IntPtr(0));
SendMessage(this->lvDestination->Handle, Convert::ToUInt32(WM_VSCROLL), System::UIntPtr(Convert::ToUInt64(ScrollEventType::SmallDecrement)), System::IntPtr(0));
}


private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {
SendMessage(this->lvSource->Handle, Convert::ToUInt32(WM_VSCROLL), System::UIntPtr(Convert::ToUInt64(ScrollEventType::SmallIncrement)), System::IntPtr(0));
SendMessage(this->lvDestination->Handle, Convert::ToUInt32(WM_VSCROLL), System::UIntPtr(Convert::ToUInt64(ScrollEventType::SmallIncrement)), System::IntPtr(0));
}



Thank you very much.
 
Back
Top