By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,558 Members | 1,533 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,558 IT Pros & Developers. It's quick & easy.

track page in listview

P: n/a
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);
}


}
}
Jul 21 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Cor
Hi Anushya,

Maybe you can have a look on "explorer" how that is done,
That is a kind listview also,

It has a treeview on the left

A very by all users accepted method to see a listview

Just a thought,

Cor
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);
}


}
}

Jul 21 '05 #2

P: n/a


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 21 '05 #3

P: n/a

Hi Cor
Thanks for ur suggestion. To let me try that, Can u pls provide the link
or can u mail me to v_*******@hotmail.com.

thanks
Anushya

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 21 '05 #4

P: n/a
Hi Cor

In Explorer Left is the treeview and the right one which is a listview
might not exceed generally like wot i ask.. Nearly 200,000 items. The
Examples provided in the net just added items. That will take a lot of
time..

Thanks for ur suggestion Cor..
Anushya


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 21 '05 #5

P: n/a
Cor
Hi Anushya,

I would fill my dataset for the listview, I asume you are using that, with
the values from the treeview, the same way as explorer does it I asume.

Going down 199.999 items when you want that one before the left is not that
user friendly in my opinion.

But it is just my opinion

Cor

In Explorer Left is the treeview and the right one which is a listview
might not exceed generally like wot i ask.. Nearly 200,000 items. The
Examples provided in the net just added items. That will take a lot of
time..

Jul 21 '05 #6

P: n/a

Hi Cor!!!
I am trying to populate all the mail items in outlook. In the worse case
it may even go to 200,000 items.

If i added items using addrange, machine hangs for just above 2500
items. I consider user friendliness and asking for performanace. Is it
ok?

Anyone pls let me know how to increase the peformance of listview when
the number of items to be populated in listview is huge?

Anushya

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 21 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.