Scrolling ListView

.net , csharp Egypt
  • 13 years ago

    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.

Post a reply

No one has replied yet! Why not be the first?

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“The most exciting phrase to hear in science, the one that heralds new discoveries, is not 'Eureka!' but 'That's funny...'” - Isaac Asimov