Presentation Problem

barski

Junior Contributor
Joined
Apr 7, 2002
Messages
240
Location
Tennessee
Here's the situation. I have a class let's call it xColl that implements the IList and gathers all the information the user needs but the client wants it displayed in a specific manner For example....

xColl fields are Customer, Orders, Returns, Payments

The user wants separate sections for Order, Returns, Payments on the Form

Moreover, the number of fields returned is not constant some customers may have 10 orders other may have 2

Any ideas???
 
As I see it your approach is all wrong right from the biggining...
What you have is a relational database scenario, and you're dealing with it as a class... having redundant data all over the place...

This is the perfect scenario to use a DataSet...
Even if you don't want to persist the data to a database or XML, your work will be a lot easyer this way.

Once the data its structured you can display the customers on a ListBox and display the related Orders on a DataGrid/ListView.

This way you'll have much less dificulty to add more columns to your order table... everything willl work as smooth as it can be...



Just a final note:
A similar result can be achieved using classes... but not IList inherited ones.
Code:
    <Serializable()> Public Class Client
        Private _orders As Order()

        Public Name As String
        Public Address As String
        Public Phone As String

        Public Property Orders() As Order()
            Get
                Return _orders
            End Get
            Set(ByVal Value As Order())
                _orders = Value
            End Set
        End Property
        Public Sub AddOrder(ByVal order As Order)
            Me._addOrder(order)
        End Sub
        Public Sub AddOrder( _
            ByVal number As Integer, _
            ByVal stockitem As String, _
            ByVal qt As Double, _
            ByVal price As Double)

            Dim nOrder As New Order
            nOrder.Number = number
            nOrder.StockItem = stockitem
            nOrder.Qt = qt
            nOrder.Price = price

            Me._addOrder(nOrder)
        End Sub

        Private Sub _addOrder(ByVal order As Order)
            If Me._orders Is Nothing Then
                ReDim Me._orders(0)
                Me._orders(0) = order
            Else
                ReDim Preserve Me.Orders(Me.Orders.Length)
                Me.Orders(Me.Orders.Length - 1) = order
            End If
        End Sub
    End Class

    <Serializable()> Public Class Order
        Public Number As Integer
        Public StockItem As String
        Public Qt As Double
        Public Price As Double
    End Class

As you can see this approach is alot harder to do... and it will get arder as it goes on...

Alex :p
 
Umm. I think maybe I didn't make some things clear in my orginal post.

The class that implements the IList is a collection of Datarows that are created when the forms loads and stored in a listbox. So when the user clicks a specific customer the pertinent collection is returned. Moreover, there are calculated fields that will have things like divide by zero so I chose a class to handle things like that. So all the data is returned but the user wants the data broken up into three different sections on the form now if the data was presented in something like a textbox it would be easy I could position the appropriate textboxes in the appropriate sections an all is right in the world. In short if something like the datarepeater existed in the .net then my problem would be solved. My hope was that there was solution for what the repeater use to do or maybe something more obvious that is escaping me

By writng this I think I've come to a conclusion. I'll use 3 datagrids with and use the columnstyles so it only is displays certain items and come up with some way to handle the extras rows.
 
I still can't visualize your issue here...

Doesn't my classes structure, simulating a relational database, solve your problems?
Instead of a simple: Public Name as string you can have: Public property Name as string, and handle the way the data is retreaved...

I'm really not undestanding your problem...
 
Here's a small sample.. For demonstration purpose I've kept it very basic but it does demonstrate the issue I hope

The collection rows returned.....

Customer Orders Returns Payments Period

CustomerA 100.00 15.00 65.00 Jan2004
CustomerA 63.15 0.00 15.15 Feb2004
CustomerA 690.00 0.00 4.14 Mar2004


The user wants three distinct sections for display purposes.......

Orders
CustomerA 100.00 Jan2004
CustomerA 63.15 Feb2004
CustomerA 690.00 Mar2004

Returns
CustomerA 15.00 Jan2004
CustomerA 0.00 Feb2004
CustomerA 0.00 Mar2004

Payments
CustomerA 65.00 Jan2004
CustomerA 15.15 Feb2004
CustomerA 4.14 Mar2004


Some customers will have more than three months of activity... So i think the 3 datagrids with a columnstyles defined will do the trick but it seems a little excessive
 
You can have a ComboBox or a ListBox to select the Customer.
Then, bellow, have a TabControl with the three categories: Orders, Return Payments.
On each TabPage, place a DataGrid like you said.

It's an idea...

Alex :p
 
Back
Top