0

I'm writing a quiz application.

Every question has 5 possible answers, so I've used 5 RadioButtons to get the answer selected.

It happens that the text of some answers is too long and part of it isn't shown.

Is it possible to show the text of a RadioButton on multiple lines?

genespos
  • 3,211
  • 6
  • 38
  • 70

1 Answers1

0

Please try this code on the Radiobutton's TextChanged Event. And change the Radiobutton's Property (AutoSize=False).

Private Sub RadioButtonOptionD_TextChanged(sender As Object, e As EventArgs) Handles RadioButtonOptionD.TextChanged
    Dim s As New Size()
    s.Width = RadioButtonOptionD.Size.Width
    s.Height = 0
    If RadioButtonOptionD.Text.Length() <= 100 Then
        s.Height = 60
        RadioButtonOptionD.Size = s
    ElseIf RadioButtonOptionD.Text.Length() <= 200
        s.Height = 80
        RadioButtonOptionD.Size = s
    ElseIf RadioButtonOptionD.Text.Length() > 200
        s.Height = 100
        RadioButtonOptionD.Size = s
    End If

Adjusting the height of the RadioButton according to the lines of its text. if the RadioButton has more then 2 lines? then it will change the height of the Radio button up to 150.

    If RadioButtonOptionD.Text.Split(vbNewLine).Count >= 2 Then  
        s.Height = 150
        RadioButtonOptionD.Size = s
    End If
    RadioButtonOptionD.Refresh()
End Sub