|
-
May 28th, 2011, 08:12 PM
#1
Thread Starter
New Member
[RESOLVED] Populating textfields with data from listview
So I have been searching for a while now with no luck.
What I want to do is gather the data that displays in my listview (called 'lstData') when selected and populate my textfields with it's information.
Pretty simple, I know. =S
Here's the rub.
SelectedItem, SelectedIndex, etc... any of these selected variations aren't working for me. I get this error message "'SelectedIndex' is not a member of 'System.Windows.Forms.ListView'".
Database: Sql Server
Here is my code, hopefully someone can see what I have done wrong?
Private Sub lstData_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstData.SelectedIndexChanged
'declare myCourse variable
Dim myCourse As New Courses
'populate myCourse with selected item
myCourse = lstData.SelectedItems
'set variables
txtId.Text = myCourse.id
txtName.Text = myCourse.name
txtAbbrev.Text = myCourse.abbrev
dtpStart.Value = myCourse.sdate
dtpExpiry.Value = myCourse.edate
txtInstructor.Text = myCourse.instr
cbType.SelectedItem = myCourse.type
txtCost.Text = myCourse.cost
txtCompany.Text = myCourse.comp
rtxtDetails.Text = myCourse.details
txtTime.Text = myCourse.time
'id textfield is now viewable
txtId.Visible = True
'makes it so that you cannot update course's ID when selected in list box.
txtId.Enabled = False
End Sub
I feel as though I've exhausted every option.
Any ideas would be greatly appreciated. Thanks guys!
-
May 28th, 2011, 08:16 PM
#2
Thread Starter
New Member
Re: Populating textfields with data from listview
Sorry, selecteditems.. selectedindex... either way I go I get the same error message just a different selection type.
-
Jun 3rd, 2011, 02:11 PM
#3
Thread Starter
New Member
Re: Populating textfields with data from listview
So I ended up figuring out what was wrong...
I was using a ListBox when I should have been using a ListView. I must have accidentally dragged the wrong one over when creating my GUI.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|