Hello everyone!
I'm declaring my Graphics object like this :
As you can see, I declared an array named sPicText with 8 elements, and also declared an integer named iPicIndex this will increment, based on a button being clicked, or decrement based on another button being clicked.Code:Private bCircle As New Bitmap(700, 700) 'Declare The Graphics Object To Draw Onto Private gCircle As Graphics = Graphics.FromImage(bCircle) Private sPicText(7) As String Private iPicIndex As Integer
I initialise my array like this :
Now, I want to use Graphics.DrawString to draw the particular array, based on the index. When the form is loaded, it does show the contents of sPicText(0), which is "Picture 1 ( One )".Code:Private Sub frmPreview_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load iPicIndex = 0 sPicText(0) = "Picture 1 ( One )" sPicText(1) = "Picture 2 ( Two )" sPicText(2) = "Picture 3 ( Three )" sPicText(3) = "Picture 4 ( Four )" sPicText(4) = "Picture 6 ( Six )" sPicText(5) = "Picture 1 ( Seven )" sPicText(6) = "Picture 8 ( Eight )" sPicText(7) = "Picture 9 ( Nine )" gCircle.DrawString(sPicText(iPicIndex).ToString, New System.Drawing.Font("Arial", 14, FontStyle.Bold, GraphicsUnit.Pixel), Brushes.AliceBlue, pic5.Left, pic5.Top) End Sub
When I click the next button, it is supposed to update this string that is being drawn. Same With the Previous button. Here's the code :
Even when clicking either of these buttons umpteen times, the string doesn't get updated. It remains with "Picture 1 ( One )", IOW. sPicText(0)Code:Private Sub btnNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNext.Click iPicIndex += 1 If iPicIndex > 7 Then iPicIndex = 0 gCircle.DrawString(sPicText(iPicIndex).ToString, New System.Drawing.Font("Arial", 14, FontStyle.Bold, GraphicsUnit.Pixel), Brushes.AliceBlue, pic5.Left, pic5.Top) End Sub Private Sub btnPrev_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrev.Click iPicIndex -= 1 If iPicIndex < 0 Then iPicIndex = 7 gCircle.DrawString(sPicText(iPicIndex).ToString, New System.Drawing.Font("Arial", 14, FontStyle.Bold, GraphicsUnit.Pixel), Brushes.AliceBlue, pic5.Left, pic5.Top) End Sub
How can I update this ?




Reply With Quote