Click here to Skip to main content
15,888,202 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi! I am new in vb.net. Hope you could help me with my question.

First, I created a class to collect user inputs.


Public Class Memory

    '--for frmcashreimbursement
    Private ushortname, usectionname As String

    '--for frmselectworkname
    Private uworkname, uworkid As String

    '--for frmCashadvreimbursement
    Private udate, uwhere, uwhy, uamount As String

    '--for frmreportregscr
    Private urepregdate, urepregpay, urepregpayee, urepregamount As String

    '--for frmReportingParticipantList
    Private uparticipants As Object

    '--for frmReportingResult
    Private ureasons, uagenda, umemo As String

    Public Property get_ushortname() As String
        Get
            Return ushortname
        End Get
        Set(value As String)
            ushortname = value
        End Set
    End Property

    Public Property get_usectionname() As String
        Get
            Return usectionname
        End Get
        Set(value As String)
            usectionname = value
        End Set
    End Property


    Public Property get_uworkname() As String
        Get
            Return uworkname
        End Get
        Set(value As String)
            uworkname = value
        End Set
    End Property


    Public Property get_uworkid() As String
        Get
            Return uworkid
        End Get
        Set(value As String)
            uworkid = value
        End Set
    End Property


    Public Property get_udate() As String
        Get
            Return udate
        End Get
        Set(value As String)
            udate = value
        End Set
    End Property


    Public Property get_uwhere() As String
        Get
            Return uwhere
        End Get
        Set(value As String)
            uwhere = value
        End Set
    End Property

    

    Public Property get_uwhy() As String
        Get
            Return uwhy
        End Get
        Set(value As String)
            uwhy = value
        End Set
    End Property



    Public Property get_uamount() As String
        Get
            Return uamount
        End Get
        Set(value As String)
            uamount = value
        End Set
    End Property


    Public Property get_urepregdate() As String
        Get
            Return urepregdate
        End Get
        Set(value As String)
            urepregdate = value
        End Set
    End Property


    Public Property get_urepregpay() As String
        Get
            Return urepregpay
        End Get
        Set(value As String)
            urepregpay = value
        End Set
    End Property


    Public Property get_urepregpayee() As String
        Get
            Return urepregpayee
        End Get
        Set(value As String)
            urepregpayee = value
        End Set
    End Property


    Public Property get_urepregamount() As String
        Get
            Return urepregamount
        End Get
        Set(value As String)
            urepregamount = value
        End Set
    End Property



    Public Property get_uparticipants() As Object
        Get
            Return uparticipants
        End Get
        Set(value As Object)
            uparticipants = value
        End Set
    End Property



    Public Property get_ureasons() As String
        Get
            Return ureasons
        End Get
        Set(value As String)
            ureasons = value
        End Set
    End Property



    Public Property get_uagenda() As String
        Get
            Return uagenda
        End Get
        Set(value As String)
            uagenda = value
        End Set
    End Property


    Public Property get_umemo() As String
        Get
            Return umemo
        End Get
        Set(value As String)
            umemo = value
        End Set
    End Property


End Class


Then After this, I created a module to hold the user inputs and store them in a collection.

    Public Class consolidate
        Sub New()


            Dim data As New Memory
1:          data.get_uworkid = uworkid
2:          data.get_uworkname = uworkname
3:          data.get_usectionname = usectionname
4:          data.get_ushortname = ushortname
5:          data.get_udate = udate
6:          data.get_uwhere = uwhere
7:          data.get_uwhy = uwhy
8:          data.get_uamount = uamount
9:          data.get_urepregdate = urepregdate
10:         data.get_urepregpay = urepregpay
11:         data.get_urepregpayee = urepregpayee
12:         data.get_urepregamount = urepregamount
13:         data.get_uparticipants = uparticipants
14:         data.get_uagenda = uagenda
15:         data.get_ureasons = ureasons
16:         data.get_umemo = umemo


            counter = counter + 1

            memorydata.Add(data, counter)

            pList.Add(data, counter.ToString)


Now my problem is I have to Display the collection in a datagridview. But i also need to filter my collection.
Say i need to display just the ones that has the same Value in its Property.

Can i use keys to access that data in my collection and show it in a datagrid. Thank You.

I was wondering of this code.
Datagridview1.Datasource = CollectionName("Filter????")
Posted
Updated 7-Aug-13 22:40pm
v2

1 solution

 
Share this answer
 
v3
Comments
naviruishen 8-Aug-13 5:51am    
The first link is Ok. The second i dont understand :(
Im developing a windows form application.
ridoy 8-Aug-13 5:54am    
yes i know it,but i refer it to you for these lines of code..
Private Sub CollectionViewSource_EuropeFilter(sender As Object, e As FilterEventArgs)
Dim country As Country = TryCast(e.Item, Country)
e.Accepted = (country.Continent = Continent.Europe)
End Sub
where filtering is applied in a collection.You could also view http://msdn.microsoft.com/en-us/library/ybcx56wz.aspx#BKMK_LINQ which will help in filtering.
Manas Bhardwaj 8-Aug-13 11:35am    
Yes 5!
ridoy 8-Aug-13 11:49am    
Thanks Manas,:)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900