473,386 Members | 1,726 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Scrolling A ListView

Hi,

How do you programmatically scroll a ListView control horizontally?
(The same effect as if the user used the horizontal scroll bar,)
I've done it in C++/MFC, but can't find the means in C#. Autoscroll
is enabled.

Also, I need to know if the user scrolls the ListView horizontally.

Thanks,
Gary
Nov 16 '05 #1
2 12498
Gary,

How did you do it in C++/MFC? If you are sending a windows message,
then you can easily do this by declaring the SendMessage function and call
it through the P/Invoke layer, passing the appropriate arguments.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Gary Brown" <ga********@charter.net> wrote in message
news:uY**************@TK2MSFTNGP09.phx.gbl...
Hi,

How do you programmatically scroll a ListView control horizontally?
(The same effect as if the user used the horizontal scroll bar,)
I've done it in C++/MFC, but can't find the means in C#. Autoscroll
is enabled.

Also, I need to know if the user scrolls the ListView horizontally.

Thanks,
Gary

Nov 16 '05 #2
To scroll the listview horizontally, I believe you'll have to use the
SendMessage API, e.g.

[DllImport("user32")]
static extern IntPtr SendMessage(IntPtr Handle, Int32 msg, IntPtr wParam,
IntPtr lParam);

protected void ScrollH(int pixelsToScroll)
{
const Int32 LVM_FIRST = 0x1000;
const Int32 LVM_SCROLL = LVM_FIRST + 20;
SendMessage(lvwList.Handle, LVM_SCROLL, (IntPtr) pixelsToScroll,
IntPtr.Zero);
}

To know when the user scrolls horizonatally, you'll need to capture the
WM_HSCROLL message in the WndProc() method, e.g.

protected override void WndProc(ref Message m)
{
const Int32 WM_HSCROLL = 0x114;

if (m.Msg == WM_HSCROLL)
HandleHorizontalScroll();

base.WndProc(ref m);
}

I'd recommend you subclass the ListView control and then add these methods
to it to achieve what you're looking for.

Ken
"Gary Brown" <ga********@charter.net> wrote in message
news:uY**************@TK2MSFTNGP09.phx.gbl...
Hi,

How do you programmatically scroll a ListView control horizontally?
(The same effect as if the user used the horizontal scroll bar,)
I've done it in C++/MFC, but can't find the means in C#. Autoscroll
is enabled.

Also, I need to know if the user scrolls the ListView horizontally.

Thanks,
Gary

Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: Wiktor Zychla | last post by:
today we've found a critical issue regarding the ListView from Windows.Forms. it was confirmed on several machines with Win2K and XP. here's the problem: create a ListView with about 50000 rows....
1
by: SlantyOD | last post by:
Hi All, I'm trying to tie two ListViews together so that when the user scrolls one, the other stays 'in sync'. Since there are no OnScroll events, and the scroll bar position is unavailable,...
0
by: Tim Bücker | last post by:
Hello. I have a listview and a listbox. If the listbox gets vertically scrolled, the listview should make the same movement. So I have extended the listbox control: public class...
0
by: Tim Bücker | last post by:
Hello. Is it really not possible to hide the scrollbars of a listview ( this.listview.Scrollable = false; ) but do some scrolling anyway ( for instance: PostMessage(this.listview.Handle,...
3
by: Oddball | last post by:
Hello again, I have a problem that I can't seem to find any help for. I'm probably not typing the correct words into goo... *cough*... MSN. I have created a user control which I would like to...
5
by: Wicksy | last post by:
Hi all. I have a VB.NET app with a loop running that is continually managing a number of threads AND updating a ListView object depending on the results of the worker threads. The problem I...
4
by: Lars Netzel | last post by:
I have a long list of Items in a ListView... if I scroll down to something that is not visible without scrolling and then click on it I open another window where you can work with the details of...
5
by: Martin Horn | last post by:
Hi all, I want to implement a listview with editable subitems and I assume the easiest way is to overlay a textbox over the item to be edited. With this in mind I have come up with: Using...
5
by: Spam Catcher | last post by:
Hi all, Is it possible to do a console like scrolling window in a Windows Form app? The closest I've gotten is to use a RichTextBox and append text to it. However, after a while, there is...
0
by: Jarppi | last post by:
Hi All, Not sure how to go about this one. I've got a windows form with five ListView controls, each listing the files in a seperate folder. What I want to achieve is this: When I scroll any...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.