|
-
Oct 24th, 2008, 07:40 PM
#1
Thread Starter
Hyperactive Member
[2008] Getting SelectedIndex of ListView For DataRow When . . .
Alright. I have a List View:
and 3 Buttons
First Button : ALL
Second Button : Incomplete
Third Button : Complete
Now I have a Access Database that has Data In it, and a Column called Completed.
The Rows Either have True or False for that Column.
Now when I click Incomplete only the Rows with False in it will show, and vice versa for Complete.
This all works. But now I run into a Problem.
Here is some Test Data for my Problem:
Code:
1 False 09/09/09
2 False 09/08/08
3 True 09/07/07
So now those will show in ALL, but When I click COmplete, only "3" will show, but when I go to click on it, and Click Edit to Fill my Text Boxes with the Data, It gets the Data from the Selected Index ("0") which would get data for "1".
So here is my Code to Get the Index & Load to Text Boxes, I don't know how to get the Selected Item to load for that piece of Item.
-
Oct 24th, 2008, 07:45 PM
#2
Re: [2008] Getting SelectedIndex of ListView For DataRow When . . .
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Oct 24th, 2008, 07:45 PM
#3
Thread Starter
Hyperactive Member
Re: [2008] Getting SelectedIndex of ListView For DataRow When . . .
lol, omg, I'm sorry :P
Code:
Public Sub LoadToTextBoxes()
With frmAssignments
Adapter.SelectCommand = New OleDbCommand("SELECT * FROM [Assignments]")
Adapter.SelectCommand.Connection = Connection
DS = New DataSet()
Adapter.Fill(DS)
Dim DRow As DataRow
Dim selNdx As Integer = .lstAssign.SelectedIndices(0)
DRow = DS.Tables(0).Rows(selNdx)
.txtAssignments.Text = DRow.Item("Assignment").ToString
.dtpDueDate.Value = Date.Parse(DRow.Item("DueDate").ToString)
.cbCompleted.Checked = CBool(DRow.Item("Completed").ToString)
'.cmbSubject.SelectedItem = DRow.Item("Subject").ToString
.txtGrade.Text = DRow.Item("Weight").ToString
.txtDesc.Text = DRow.Item("Description").ToString
End With
End Sub
-
Oct 24th, 2008, 07:54 PM
#4
Re: [2008] Getting SelectedIndex of ListView For DataRow When . . .
is your listview multiselect property set to true?
do you want the index of the last selecteditem?
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Oct 24th, 2008, 07:56 PM
#5
Thread Starter
Hyperactive Member
Re: [2008] Getting SelectedIndex of ListView For DataRow When . . .
ListView is not Multiselect, its Full Row Select, and only gets the Index of the Selected Row
And I want the Index of the Item I choose, so say I go into Complete and the First 2 Items are Incomplete then in my Database the CIndex (CIndex is a AutoIncrement # that gets Created with Each Item) would be
1
2
3 < This one I want
but when I go to Complete in the ListView, the Index is 0.
-
Oct 24th, 2008, 08:24 PM
#6
Re: [2008] Getting SelectedIndex of ListView For DataRow When . . .
i don't understand. you want it to return the selectedindex?
or you want it to loop through the listviewitems + find the 1st 1 thats complete?
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Oct 25th, 2008, 07:57 AM
#7
Thread Starter
Hyperactive Member
Re: [2008] Getting SelectedIndex of ListView For DataRow When . . .
Ok, see I don't know what I need to find. What I want to do is.
Code:
NAME | COMPLETED | DATE
1 False 09/09/09
2 False 09/08/08
3 True 09/07/07
Their is my Test Data.
Now I have 3 Views in the ListView (Completed, Incomplete'd, and All)
So What I'm trying to do is, find a Way when I completed or Incompleted Clicked, that I can get the Proper Index or Something, to match up according to What Button I pressed.
All will show what is above.
Completed would only show
3 True 09/07/07
Incomplete would only show
1 False 09/09/09
2 False 09/08/08
But the CIndex of the Data is 1, 2, 3. (CIndex is the AutoIncrement # I get for a Unique Piece of Data).
So, when I click the Complete Tabl, only "3" will show: And when I click it, and press EDIT, it will fill the TextBoxes with Incomplete "1" because that's the Index in the ListView that Corresponds to the CIndex in the Database File.
Makes anymore Sense?
-
Oct 27th, 2008, 03:09 PM
#8
Thread Starter
Hyperactive Member
Re: [2008] Getting SelectedIndex of ListView For DataRow When . . .
Anyone? Still having trouble with this issue.
-
Oct 27th, 2008, 08:38 PM
#9
Re: [2008] Getting SelectedIndex of ListView For DataRow When . . .
I haven't read this thread in detail but it seems to me that the ListView is the wrong control for this. If you are only using Details View and you aren't using the grouping functionality then why use a ListView instead of a DataGridView? With a DGV you simply bind your DataTable to a BindingSource and bind that to the grid. Filtering is simply a matter of setting the Filter property of the BindingSource. It's two lines of code to bind the data in the first place and one line to filter each time.
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
|