b b

b b

  • NA
  • 53
  • 0

Mouse Operation

Sep 18 2009 1:26 AM
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

Answers (3)