Mouse Operation
Hi everyone,
I have the following codes for mouse scrolling over data inside a ListView item. Here I am using ListView "listView1" in the form. The codes are working fine. But I want to make this code inside a class file so that for various ListView i can use the same code. I just want to pass the different different ListView name as a parameter to this function. I tried but its throwing errors. Can anyone help me on this.
private void listView1_MouseWheel(object sender, MouseEventArgs e)
{
try
{
if (e.Delta <= 0)
{
index = listView1.SelectedIndices[0];
if (index <= listView1.Items.Count - 1)
{
i++;
listView1.Items[i].Selected = true;
listView1.Select();
}
else
{
listView1.Items[listView1.Items.Count- 1].Selected=true;
listView1.Select();
}
}
else if (e.Delta >= 0)
{
if (listView1.SelectedIndices[0] == 0)
{
listView1.Items[0].Selected = true;
}
else
{
i--;
listView1.Items[i].Selected = true;
listView1.Select();
}
}
}
catch
{
}
}
regards,
bjb
b bPosted Sep 18, 2009, 6:15 AM
Master BillaPosted Sep 18, 2009, 4:19 AM
Here is sample code to do this given in MSDN
http://msdn.microsoft.com/en-us/library/system.windows.forms.listview_events%28VS.71%29.aspx
Thank you
Roei BarPosted Sep 18, 2009, 2:33 AM