Click here to Skip to main content
15,029,369 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Guys need help. How can i select only one item in the listview and display it on the txt box?
If i change the FullRowSelect to false i cant no longer select any items in my listview
Posted
Comments
Afzaal Ahmad Zeeshan 31-Mar-15 2:01am
   
You need to have FullRowSelect as true, and then handle the SelectedIndexChanged event to preview the item inside the TextBox.
Member 11088283 31-Mar-15 4:31am
   
My problem is i have 4 columns in my listview:
Column a = name
Column b = Grade
Column c = Section
Column d = Yr

So if i click the name under column name they will be another form that will show connected to the Name of the user and If i click the the Grade under column b there will be another form that will show. Make sense?
Basically the 2 columns will be a link. connected to the diff forms. User can click/choose either name or grades.

Hi, Check MultiSelect property of ListView control.
Set this property to False for your ListView control.
For more information check this link : ListView Class - MSDN[^].
FullRowSelect property is useful when you set ListView View property to Details and your ListView contains multiple columns.
I hope this will help you. :)
   
v2
From your comment I don't believe that Solution 1 will help you.

The ListViewHitTestInfo[^] class should give you what you want.

For example:
VB
Private Sub ListView1_MouseClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListView1.MouseClick
    Dim lvi As ListViewHitTestInfo = ListView1.HitTest(e.X, e.Y)
    'I've used a message box - you can show a form
    MessageBox.Show(lvi.SubItem.Text)
End Sub

Warning - you should do some checks to make sure that the SubItem is not null, etc.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900