help with VB 2008

Associate
Joined
31 Jul 2008
Posts
1,328
Location
London
I am trying to get a panel to display 5 item from a arraylist using the graphics tool but i can only get it to display every item in the arraylist.
So if is 10 items in the arraylist the panel will show the first 5 items and if i click on the next button the panel will show items 2 - 6.

here is the code for the panel:

Code:
Private Sub pnlDisplay_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles pnlDisplay.Paint
        Dim strOutput As String
        Dim x, y As Integer
        x = 5
        y = 5
        Dim fntOut As New Font("Time New Roman", 10.0F)
        Dim currBrush As New SolidBrush(Color.Black)
        Dim i As Integer
        While i < nCurrentTask
            g.FillEllipse(colour, x, y, 15, 15)
            currTask = arrList(i)
            strOutput = currTask.GetDescription + " " + currTask.GetTaskDate
            g.DrawString(strOutput, fntOut, currBrush, x + 20, y)
            y += Convert.ToInt32(fntOut.Height)
            i += 1
            GrabInfo()
        End While
    End Sub

here is the code for the navigation button:

Code:
rivate Sub NextTask()

        If nCurrentTask < arrList.Count Then
            nCurrentTask += 1
        Else
            nCurrentTask = arrList.Count
        End If
        pnlDisplay.Invalidate()
        labelDisplay()

    End Sub

any help will be appricated

Tony
 
Last edited:
Why are you painting text to a panel if you want it uneditable use a label and turn autosize off or a listbox and prevent editting, painting it just seems messy.

Part of an excise I have got

Basically you need to only get the first 5 items then the next 5 so you need to just use an if statement in your while to only get the values from the array you need and ignore any that don't fall in your range. So when they click next you need to know where you are in the array so you can move your range accordingly.

I appricate you help but is there any chance you can simplify that if that even possible :confused:

sorry for the silly questions I am new at this
 
Back
Top Bottom