C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Forums » .NET » .NET »

Listview small probs


Posted Date: 03 Jul 2009      Posted By: ritu      Member Level: Silver     Points: 1   Responses: 1



ListView Properties- I set MultiSelect to False, LabelEdit to true,FullRowSelect to True. I have Listview with two columns.

[B]1) [/B]When I select onw row in listview,On button click i want to get the index of selected row. I m getting it but using for loop,I want to know is there a way to know the index of selected row,Without using the for loop.


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim lCount As Integer
If ListView1.SelectedItems.Count > 0 Then
For lCount = 0 To ListView1.Items.Count - 1
If ListView1.Items(lCount).Selected Then
MsgBox(lCount.ToString)
End If
Application.DoEvents()
Next
End If
End Sub


[B]2) [/B] On Listview, double click,i want to edit the items of listview.


Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim lCount As Integer
Dim lvitem As ListViewItem

For lCount = 1 To 3
lvitem = ListView1.Items.Add(lCount)
lvitem.SubItems.Add("ritu" & lCount)
Application.DoEvents()
Next
End Sub

Private Sub ListView1_MouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListView1.MouseDoubleClick
ListView1.SelectedItems(0).BeginEdit()
End Sub


When we double click on first row, 1 comes to edit mode, i want to know i want that second column text comes to edit mode..
So i write

ListView1.SelectedItems(1).BeginEdit()


But Error is there- InvalidArgument=Value of '1' is not valid for 'index'.
Parameter name: index

Can somebody tell me how to edit the second column text.





Responses

Author: ABitSmart    03 Jul 2009Member Level: DiamondRating: 2 out of 52 out of 5     Points: 2

No idea of your original problem.

But, if you are setting MultiSelect to False then why are you using SelectedItems? You should be using SelectedItem.

DNS MVM
My blog
Thoughts.exe



Post Reply
You must Sign In to post a response.
Next : How to run !^ bit application using c#
Previous : internal keyword
Return to Discussion Forum
Post New Message
Category: .NET

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use