473,595 Members | 2,636 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Slow listview

Hi
I am using Listview and inherited listview control overriding WndProc
& PreProcessMessa ge in ListView.

I need this to customize listview to display only the page the user
scrolls to. Since i am populating listview with more than 200,000
items. It is too slow and tried virtual listview. But that doesnot
allow me to add images in the listview. So now trying to list only the
page user scrolls to.

Tried to keep track of the current page by simple logic. Now want to
know whether is there anyother way of keeping track of the PAGE THE
USER SCROLLS to. I know in advance the number of items in the
listview. Also know the no. of items in each page.

Wot change i need to do to keep track of the current page in
listview??

Also let me know is there any way to speed listview. I tried sorting
to be false and also tried lockwindowupdat e api. It had only little
effect. Then also tried virtual listview.. Its performance is very
good but could not add images. Pls let me know how to speeed listview
for nearly 200,000 items(adding images too).

Will this logic of listing the page only the user requested scrolled
to will work (without flickering??)..

using System;
using System.Collecti ons;
using System.Componen tModel;
using System.Drawing;
using System.Data;
using System.Windows. Forms;

namespace CtrPagingListVi ew
{
public class CtrPagingListVi ew : System.Windows. Forms.ListView

{

const int WM_HSCROLL = 0x0114;
const int WM_VSCROLL = 0x0115;
protected const int WM_KEYDOWN = 0x0100;
protected const int VK_LEFT = 0x0025;
protected const int VK_UP = 0x0026;
protected const int VK_RIGHT = 0x0027;
protected const int VK_DOWN = 0x0028;
public int i = 11;
private System.Componen tModel.Containe r components = null;

// store the item count to prevent the call to
SendMessage(LVM _GETITEMCOUNT)
private int itemCount = 0;
public int ItemCount
{
get { return itemCount; }
set
{
itemCount = value;
int result;
result = WindowsFunction .SendMessage(
this.Handle,
(int)ListViewMe ssages.LVM_SETI TEMCOUNT,
itemCount,
0);
}
}

public CtrPagingListVi ew()
{
InitializeCompo nent();

}

protected override void WndProc(ref System.Windows. Forms.Message
msg)
{

int NUMLINES = 5000;

int numLinesPerpage = 12;

if(msg.Msg == WM_HSCROLL)
{System.Windows .Forms.MessageB ox.Show("WM_HSC ROLL
message","sdf") ;}

if(msg.Msg == WM_VSCROLL)
{
System.IntPtr param = msg.WParam;
switch ((int)param)
{
case 7:
System.Windows. Forms.MessageBo x.Show("SB_BOTT OM message" +
(NUMLINES - numLinesPerpage ) + "to" + NUMLINES);
i = NUMLINES - numLinesPerpage ;
// nVscrollInc = nVscrollMax - nVscrollPos;
break;

case 0:
//nVscrollInc = -1;
System.Windows. Forms.MessageBo x.Show("SB_linw up WM_HSCROLL
message" + i + " to " + (i - 1));
i = i - 1;
break;

case 1:
//nVscrollInc = 1;
System.Windows. Forms.MessageBo x.Show("SB_LINE down message" + i +
"to" + (i + 1));
i = i + 1;
break;

case 2:
// nVscrollInc = min (-1, -cyClient / cyChar);
System.Windows. Forms.MessageBo x.Show("SB_PAGE UP message"+ i +
"to" + (i-numLinesPerpage )); i = i-numLinesPerpage ;
break;

case 3:
// nVscrollInc = max (1, cyClient / cyChar);
System.Windows. Forms.MessageBo x.Show("SB_PAGE DOWN message" + i +
" to " + (i+numLinesPerp age));
i = i+numLinesPerpa ge;
break;

case 5:
// nVscrollInc = LOWORD (lParam) - nVscrollPos;
System.Windows. Forms.MessageBo x.Show("SB_THUM BTRACK
message","sdf") ;
break;

}
} base.WndProc(re f msg);
}
protected override void OnMouseUp(Mouse EventArgs e)
{
System.Windows. Forms.MessageBo x.Show("ONMOuse down" + e.X + " Delta
" + e.Delta);
System.Windows. Forms.MessageBo x.Show("ONMOuse down" + e.Y);
base.OnMouseUp( e);
}

public override bool PreProcessMessa ge(ref
System.Windows. Forms.Message msg)
{
//Convert key code to a .NET Keys structure
// Convert key code to a .NET Keys structure
Keys keyData = ((Keys) (int) msg.WParam) | ModifierKeys;
Keys keyCode = ((Keys) (int) msg.WParam);

// handle message
if (keyData == Keys.Next)
{
System.Windows. Forms.MessageBo x.Show("next page" + i + "to" + (i
+ 9));

i = i + 9;
}
else if (keyData == Keys.Prior)
{
System.Windows. Forms.MessageBo x.Show("prev message" + i + "to" +
(i - 9));

i = i - 9;

}
else if (keyData == Keys.Up)
{
System.Windows. Forms.MessageBo x.Show("UP" + i + "to" +( i - 1));

i = i - 1;
}
else if (keyData == Keys.Down)
{
System.Windows. Forms.MessageBo x.Show("DOWN" + i + "to" + (i +
1));
i = i + 1;
}
else if (keyData == Keys.Left)
{
System.Windows. Forms.MessageBo x.Show("Left");

}
else if (keyData == Keys.Right)
{
System.Windows. Forms.MessageBo x.Show("Right") ;

} return base.PreProcess Message(ref msg);
}


}
}
Nov 22 '05 #1
0 1840

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

Similar topics

0
489
by: Anushya | last post by:
Hi I am using Listview and inherited listview control overriding WndProc & PreProcessMessage in ListView. I need this to customize listview to display only the page the user scrolls to. Since i am populating listview with more than 200,000 items. It is too slow and tried virtual listview. But that doesnot allow me to add images in the listview. So now trying to list only the page user scrolls to.
4
329
by: ?BOT | last post by:
Why is the following code so slow? I have a listView that must refresh it's processes data every 3 seconds. However, this sometimes goes beyond 5 seconds and crashes the application. I have tries multi-threading, also ListView.BeginUpdate + EndUpdate(), but the code is sooo slow. Try it for yourself: Public Sub UpdateData() On Error Resume Next Me.ListView1.Clear() For Each process As System.Diagnostics.Process In
2
9024
by: cybertof | last post by:
Hello, Is there a solution to the following problem : When filling a listview (30 columns) with around 5000 items, it can take easily 10 sec for the listview to be filled. I have used BeginUpdate and SuspendLayout but no speed... Here is a flavor of the code :
21
1546
by: TryingLikeHeck | last post by:
I have an application that uses a LIstView. Maybe 100 items each with 20 subitems. The app looks at eack item and subitem twice. I.e., it scans the entire set of data item1, sub1,sub2,... item2,sub1,sub2... .. .. twice
14
1473
by: Marten Van Keer | last post by:
Given two .NET applications A and B. These two application communicate with each other by using an object C: A --> C <-- B Application A has a listview. This listview can be refreshed by pressing F5 OR externally by receiving an event from C. C will raise an event when it receives data from B. So, B sends a message to C. And C raises an event that is "catched" by A.
2
3465
by: johnb41 | last post by:
In my app, I need to open up a multipage tiff file, and also display it's thumbnail images IN HIGH QUALITY. (High Quality meaning anti-aliased, and looking good; not rough and pixely) The thumbnail images are displayed in a ListView control. (I go through each page of the file, create a thumbnail of it, and put it into an ImageList. Then i hook that imagelist up to the ListView.) It works fine, but it is VERY slow. Creating and...
0
7955
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7883
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8261
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8019
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8251
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
5839
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5418
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3911
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1490
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.