Still won't work for some reason. Dim StringVariable As String = lvwTeams.SelectedItems(lvwTeams.Items(0).Index).Text Still getting an argumentoutofrange exception. I'm selecting one of the items in the list and clicking a button that fires this method and I'm getting that exception. I am adding them to the listview this way:
Dim str(6) As String
Dim itm As ListViewItem
While myReader.Read()
str(0) = myReader.GetValue(2)
str(1) = myReader.GetValue(3)
str(2) = myReader.GetValue(4)
str(3) = myReader.GetValue(5)
str(4) = myReader.GetValue(6)
str(5) = myReader.GetValue(7)
itm = New ListViewItem(str)
lvwTeams.Items.Add(itm)
End While
Any other ideas?
Why do I keep getting an ArgumentOutOfRange Exception? I am using: Dim StringVariable As String = lvwTeams.SelectedItems(0).ToString
Label1.Text = StringVariable
I know I can use the SelectedItems method but that returns a ListViewItem correct? And I need to know how to convert that into something that I can use, like a string.
How can I get the selected index of the selected item in a listview and also get the text that is selected. I.E. I have a listbox with a bunch of teams in it and I want to get the text that is selected in the listview. Like if Yankees is selected, I want a string set to "Yankees". Any ideas?
I have a listview with 2 columns and I need to know how to put things in the second column. When I do a: lvwTeams.Items.Add(myReader.GetValue(6) & " (" & myReader.GetValue(2) & myReader.GetValue(3) & ")") it only puts thing in the first column. How do I do this??
This is the code I am using:
Dim MyCommand As New SqlCommand()
Dim MyConnection As New SqlConnection()
Dim MySQLDataAdapter As New SqlDataAdapter()
Dim SessionCmd As String
MyConnection = New SqlConnection("server=(local);database=StatKeeper;Trusted_Connection=yes")
SessionCmd = "Select (TeamName) FROM tmTeams"
MyCommand = New SqlCommand(SessionCmd, MyConnection)
MyCommand.Connection.Open()
Try
MyCommand.ExecuteNonQuery()
Catch Exp As SqlException
If Exp.Number = 2627 Then
Else
End If
End Try
MyCommand.Connection.Close()
I need to get all the items under a certain column in SQL and add them all to a Listview. How would I do this?
I know how to connect to SQL and add things to listview's but I don't know how to add them when it's from SQL.
No, I haven't but something must still be open. How do you close a form when a button is clicked? In VB6 I used Unload Me but in .NET you can't. What should i be doing?
How do you handle the click of the "x" in the top corner to close the application? How do you unload the application? I can do it with a button click but how do I do it with the "x"?
I am just getting into writing classes with .NET and I was wondering how I would do that following? I need a class that has 3 integer number (for serial keys) and it needs to have a validate function to validate the keys. I just need help on what goes in which methods. Like what is the new() method for and do you need to have one?
I was wondering how people put trial periods on their products. Obviously it's so many days or so many uses, but how do you make the serial numbers? It's an algorithm of some sort right? Does anyone have any info on this?
Thanks
I realize in .NET that it garbage collects automatically when needed but I am still getting memory leaks. I have a program that acts as a Robot for the web and it gets links on pages and goes to all those pages and gets those links and so on. But my memory is getting used up little by little when I let it run for about an hour. Any ideas?