Exn
Exn

Reputation: 809

Display the content of this multidimensional array correctly

In my program I have two List boxes (to pick a seller, and a product), one text box (to enter a number) and a button to store the data.

I have no problem storing the data, but I can't seem to display the content of the array correctly.

I want to display the data in a 4x3 table, in different labels.

Here is an example of how I want my table to look like:

              seller 1      seller 2      seller 3      seller 4

product 1     label 1       label 2       label 3       label 4

product 2     label 5       label 6       label 7       label 8

product 3     label 9       label 10      label 11      label 12

product 4     label 13      label 14      label 15      label 16

product 5     label 17      label 18      label 19      label 20

As I said, I want what is now stocked in the array to display in each labels.

This is what I have so far, This is my main form:

Public Class showForm
    Public Shared sale(4, 3) As Integer
    Public Shared numberProducts(4) As Integer
    Public Shared numberSellers(3) As Integer

    Public StockClass As New Stocking

    Public Shared sellerColumnInteger As Integer
    Public Shared productLineInteger As Integer

    Public Sub addButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles addButton.Click

        StockClass.addItem(sellerListBox, producttListBox, saleTextBox)

    End Sub

    Public Sub SalesByMonthToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
        Handles SalesByMonthToolStripMenuItem.Click

        saleForm.Show()
    End Sub
End Class

And then I created another class named Stocking, this is what I have in it so far (the second part is where I have trouble):

My big problem is I can't seem to add the right values in the table. Everything I've tried doesn't work the way I want it to, it either doesn't show the right number, or if it shows the right number it doesn't show the right one in another label. In other words, whenever I get something to work, something else doesn't. I believe the way I stock the values is okay, it's just the way I'm trying to display the values that is wrong.

Upvotes: 2

Views: 877

Answers (1)

NiteTrip
NiteTrip

Reputation: 198

I would store the values in a DataGridView. You can have row labels and column headings, and you can manipulate the columns however you like.

Upvotes: 1

Related Questions