473,327 Members | 1,936 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,327 software developers and data experts.

Slow listview

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.

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 lockwindowupdate 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.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;

namespace CtrPagingListView
{
public class CtrPagingListView : 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.ComponentModel.Container 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)ListViewMessages.LVM_SETITEMCOUNT,
itemCount,
0);
}
}

public CtrPagingListView()
{
InitializeComponent();

}

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

int NUMLINES = 5000;

int numLinesPerpage = 12;

if(msg.Msg == WM_HSCROLL)
{System.Windows.Forms.MessageBox.Show("WM_HSCROLL
message","sdf");}

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

case 0:
//nVscrollInc = -1;
System.Windows.Forms.MessageBox.Show("SB_linwup WM_HSCROLL
message" + i + " to " + (i - 1));
i = i - 1;
break;

case 1:
//nVscrollInc = 1;
System.Windows.Forms.MessageBox.Show("SB_LINEdown message" + i +
"to" + (i + 1));
i = i + 1;
break;

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

case 3:
// nVscrollInc = max (1, cyClient / cyChar);
System.Windows.Forms.MessageBox.Show("SB_PAGEDOWN message" + i +
" to " + (i+numLinesPerpage));
i = i+numLinesPerpage;
break;

case 5:
// nVscrollInc = LOWORD (lParam) - nVscrollPos;
System.Windows.Forms.MessageBox.Show("SB_THUMBTRAC K
message","sdf");
break;

}
} base.WndProc(ref msg);
}
protected override void OnMouseUp(MouseEventArgs e)
{
System.Windows.Forms.MessageBox.Show("ONMOusedown" + e.X + " Delta
" + e.Delta);
System.Windows.Forms.MessageBox.Show("ONMOusedown" + e.Y);
base.OnMouseUp(e);
}

public override bool PreProcessMessage(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.MessageBox.Show("next page" + i + "to" + (i
+ 9));

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

i = i - 9;

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

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

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

} return base.PreProcessMessage(ref msg);
}


}
}
Nov 22 '05 #1
0 1802

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

Similar topics

0
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...
4
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...
2
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...
21
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,......
14
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...
2
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...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.