PC Review


Reply
Thread Tools Rate Thread

Re: Yet another listview question

 
 
Aaron
Guest
Posts: n/a
 
      16th Mar 2005
Since I couldn't get anything to work good, I just ordered my
recordset and iterated till I got to a new value, when I did, I added
that item to my listview and continued the process till EOF was
reached.

On Tue, 15 Mar 2005 20:03:47 -0600, Aaron <(E-Mail Removed)>
wrote:

>Ok, here goes...I need to populate a listview with my recordset, yet
>there are multiple items with the same data, and since there is no
>built in ADO support for DISTINCT, I have to devise some way to
>populate my listview with only unique values. My first column is the
>column that is visible to the user, the second column contains an ID
>that is not visible to the user since I set the column width to 0. My
>problem is iterating through the list and checking the ID field to
>make sure it hasn't already been added, if it has, ignore and go to
>the next recordset row. Can anyone help me with this? I assume there
>is a much better way to do this. I tried posting on Peter's forum but
>I don't often get responses or find a lot of people who have used
>similar processes for a listview which seems to be one of the more
>difficult things to use.
>
> Dim rsDept As New InTheHand.Data.Adoce.Recordset
> Dim serviceID As Int32
> Dim floor As String
> Dim item As New ListViewItem
> Dim i As Integer
>
> rsDept.Open("SELECT tblServices.Number, tblServices.ServiceID,
>tblFloors.Floor FROM tblFloors INNER JOIN tblServices ON
>tblFloors.FloorID = tblServices.FloorID WHERE tblServices.Number = " &
>G_TICKET, cn)
> If Not rsDept.EOF And Not rsDept.BOF Then
> G_ACTIVATE = True
> frmDeptFloorRoom.Instance().lstDeptFloorRoom.Clear()
> rsDept.MoveFirst()
> While Not rsDept.EOF
> serviceID =
>rsDept.Fields("ServiceID").Value().ToString()
> floor = rsDept.Fields("Floor").Value()
>
> If
>(frmDeptFloorRoom.Instance().lstDeptFloorRoom.SelectedIndices.Count >
>0) Then
> For i = 0 To
>frmDeptFloorRoom.Instance().lstDeptFloorRoom.Items.Count
> item =
>DirectCast(frmDeptFloorRoom.Instance().lstDeptFloorRoom.Items(frmDeptFloorRoom.Instance().lstDeptFloorRoom.SelectedIndices.Item(1)),
>ListViewItem)
> If serviceID <> Convert.ToInt32(item) Then
> 'Add floor from current record
>
>frmDeptFloorRoom.Instance().lstDeptFloorRoom.Items.Add(New
>ListViewItem(New String() {floor, serviceID}))
> End If
> Next
> Else
>
>frmDeptFloorRoom.Instance().lstDeptFloorRoom.Items.Add(New
>ListViewItem(New String() {floor, serviceID}))
> End If
>
> rsDept.MoveNext() 'get new values from next record
> End While
> Else
> .
> .
> .
> End If


 
Reply With Quote
 
 
 
 
Alex Feinman [MVP]
Guest
Posts: n/a
 
      16th Mar 2005
That sounds like a very reasonable workaround

--
Alex Feinman
---
Visit http://www.opennetcf.org
"Aaron" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Since I couldn't get anything to work good, I just ordered my
> recordset and iterated till I got to a new value, when I did, I added
> that item to my listview and continued the process till EOF was
> reached.
>
> On Tue, 15 Mar 2005 20:03:47 -0600, Aaron <(E-Mail Removed)>
> wrote:
>
>>Ok, here goes...I need to populate a listview with my recordset, yet
>>there are multiple items with the same data, and since there is no
>>built in ADO support for DISTINCT, I have to devise some way to
>>populate my listview with only unique values. My first column is the
>>column that is visible to the user, the second column contains an ID
>>that is not visible to the user since I set the column width to 0. My
>>problem is iterating through the list and checking the ID field to
>>make sure it hasn't already been added, if it has, ignore and go to
>>the next recordset row. Can anyone help me with this? I assume there
>>is a much better way to do this. I tried posting on Peter's forum but
>>I don't often get responses or find a lot of people who have used
>>similar processes for a listview which seems to be one of the more
>>difficult things to use.
>>
>> Dim rsDept As New InTheHand.Data.Adoce.Recordset
>> Dim serviceID As Int32
>> Dim floor As String
>> Dim item As New ListViewItem
>> Dim i As Integer
>>
>> rsDept.Open("SELECT tblServices.Number, tblServices.ServiceID,
>>tblFloors.Floor FROM tblFloors INNER JOIN tblServices ON
>>tblFloors.FloorID = tblServices.FloorID WHERE tblServices.Number = " &
>>G_TICKET, cn)
>> If Not rsDept.EOF And Not rsDept.BOF Then
>> G_ACTIVATE = True
>> frmDeptFloorRoom.Instance().lstDeptFloorRoom.Clear()
>> rsDept.MoveFirst()
>> While Not rsDept.EOF
>> serviceID =
>>rsDept.Fields("ServiceID").Value().ToString()
>> floor = rsDept.Fields("Floor").Value()
>>
>> If
>>(frmDeptFloorRoom.Instance().lstDeptFloorRoom.SelectedIndices.Count >
>>0) Then
>> For i = 0 To
>>frmDeptFloorRoom.Instance().lstDeptFloorRoom.Items.Count
>> item =
>>DirectCast(frmDeptFloorRoom.Instance().lstDeptFloorRoom.Items(frmDeptFloorRoom.Instance().lstDeptFloorRoom.SelectedIndices.Item(1)),
>>ListViewItem)
>> If serviceID <> Convert.ToInt32(item) Then
>> 'Add floor from current record
>>
>>frmDeptFloorRoom.Instance().lstDeptFloorRoom.Items.Add(New
>>ListViewItem(New String() {floor, serviceID}))
>> End If
>> Next
>> Else
>>
>>frmDeptFloorRoom.Instance().lstDeptFloorRoom.Items.Add(New
>>ListViewItem(New String() {floor, serviceID}))
>> End If
>>
>> rsDept.MoveNext() 'get new values from next record
>> End While
>> Else
>> .
>> .
>> .
>> End If

>


 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Listview question BobLaughland Microsoft ASP .NET 1 8th Dec 2008 09:01 AM
Listview question Adrian Microsoft C# .NET 2 23rd Oct 2007 12:20 AM
Another ListView question whistler Microsoft Access Form Coding 1 10th Jul 2007 03:04 AM
Listview question DBC User Microsoft C# .NET 1 3rd Sep 2006 03:20 AM
Listview question Kay Microsoft VB .NET 5 22nd Aug 2006 01:34 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:47 PM.