I have successfully managed to get my data the way I want it in ListView and have two questions;

1 - How can I select an item on a single (or double) click of a mouse button that executes some code using that as the variable passed to it from a ListView entry?

2 - How can I change the order (ascending/descending) on the second column?

Thanks in advance!

You could use the ItemActivate event. You can sepcify in the ListView properties whether the item has to be clicked once or twice to activate, then use the ListView.FocusedItem property to see which item currently has focus.
Or you could set the MultiSelect property to false and use the SelectedIndex changed event to query the ListView.SelectedIndices colelction for the currently selected item.

I tried the first method you said;

textBox1.Text = listView1.FocusedItem.Text.ToString();

and placed it within the listView1 portion of the code.

The problem I am having is that it allows me to pass a value once to a textbox but then the program crashes when I make a different selection.

The error given states;

"Object reference not set to an instance of an object."

Some help would be greatly appreciated

My bad.

I had to turn 'MultiSelect' to 'True'

Thread is marked as solved.

Thanks for your help

Edited 6 Years Ago by buster2209: n/a

This question has already been answered. Start a new discussion instead.