Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I wrote the code and I think I\'ve got it right but for some reason the alignmen

ID: 3550304 • Letter: I

Question

I wrote the code and I think I've got it right but for some reason the alignments are not showing in the output. Please check my code and tell me what is wrong. (If you can, compile it to see the results).

This is the question:

Create an application that translates the Latin words to English. The form should have three bottoms, one for each Latin word. When the user clicks a button, the application should display the English translation in a Label control. When the user clicks the sinister button, the translation should appear with middle left alignment. When the user clicks the dexter button, the translation should appear with middle right alignment. When the user clicks the medium button, the translation should appear with middle center alignment.

List of Latin words and their meanings:

Latin                            English

sinister                         left

dexter                          right

medium                       center

My code:

Public Class Form1

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

    End Sub

    Private Sub btnSinister_Click(sender As Object, e As EventArgs) Handles btnSinister.Click

        'Display left.

        lblMessage.Text = "left"

        'Align to middle left

        lblMessage.TextAlign = ContentAlignment.MiddleLeft

    End Sub

    Private Sub btnDexter_Click(sender As Object, e As EventArgs) Handles btnDexter.Click

        'Display right.

        lblMessage.Text = "right"

        'Align to middle right

        lblMessage.TextAlign = ContentAlignment.MiddleRight

    End Sub

    Private Sub btnCenter_Click(sender As Object, e As EventArgs) Handles btnCenter.Click

        'Display center.

        lblMessage.Text = "center"

        'Align to middle center

        lblMessage.TextAlign = ContentAlignment.MiddleCenter

    End Sub

    Private Sub lblMessage_Click(sender As Object, e As EventArgs) Handles lblMessage.Click

    End Sub

End Class

Explanation / Answer

Do label.autosize=false before alignment