Oppure

Loading
31/03/09 20:04
carmines92
Non ho mai capito cosa vuol dire questo errore. :?
Allora io ho messo una label e voglio che quando ci passi con il mouse sopra diventa sottolineata
quindi nell'evento MouseUP della label ho messo:

Label1.Font.Underline = True

Però sotto mi compar quell'errore cioè La proprietà "Underline" è "ReadOnly"

Vi prego solo voi mi sapreste aiutare
aaa
31/03/09 20:15
Rikisonny
Usa questo codice:

   Private mThisFont As Font

   Public Sub New()
       MyBase.New()

       'This call is required by the Windows Form Designer.
       InitializeComponent()

       'Add any initialization after the InitializeComponent() call
       mThisFont = New Font("Sans Serif", 12, FontStyle.Regular)
       Label1.Font = mThisFont
   End Sub

   Private Sub Label1_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles Label1.MouseEnter
       mThisFont = New Font("Sans Serif", 12, FontStyle.Underline)
       Label1.Font.Dispose()
       Label1.Font = mThisFont
   End Sub

   Private Sub Label1_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles Label1.MouseLeave
       mThisFont = New Font("Sans Serif", 12, FontStyle.Regular)
       Label1.Font.Dispose()
       Label1.Font = mThisFont
   End Sub
aaa
31/03/09 20:15
theprogrammer
ReadOnly vuol dire in "sola lettura" (come forse saprai). Quindi, la proprietà Underline, cosi' come l'hai usata, la puoi solo leggere, non modificare.

Basta scrivere

Private Sub Label1_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Label1.MouseMove
  Dim ff As Font = sender.Font

  sender.Font = New Font(ff, ff.Style Or FontStyle.Underline)
End Sub


per usare il font della Label modificando lo stile
Ultima modifica effettuata da theprogrammer 31/03/09 20:28
aaa