Propiedad Font.

29/09/2004 - 20:26 por miguel Arenas | Informe spam
Como cambio la propiedad label1.fond.Bold=true desde
codigo, marca el error de propiedad solo lectura.
gracias.

Preguntas similare

Leer las respuestas

#6 Miguel Arenas
29/09/2004 - 21:59 | Informe spam
Se esta aplicando al lblfont y deberia ser rtbNote.
Si asi lo estoy haciedo pero no lo esta tomando. Esta es
la intruccion.


If (Not rtbNote.SelectionFont.Italic) And
rtbNote.SelectionFont.Bold And
rtbNote.SelectionFont.Underline Then
lblfont.Font = New Font(lblfont.Font,
FontStyle.Italic Or FontStyle.Bold Or FontStyle.Underline)
End If
If (Not rtbNote.SelectionFont.Italic) And
rtbNote.SelectionFont.Bold And (Not
rtbNote.SelectionFont.Underline) Then
lblfont.Font = New Font(lblfont.Font,
FontStyle.Italic Or FontStyle.Bold)
End If
If (Not rtbNote.SelectionFont.Italic) And
(Not rtbNote.SelectionFont.Bold) And
rtbNote.SelectionFont.Underline Then
lblfont.Font = New Font(lblfont.Font,
FontStyle.Italic Or FontStyle.Underline)
End If
If (Not rtbNote.SelectionFont.Italic) And
(Not rtbNote.SelectionFont.Bold) And (Not
rtbNote.SelectionFont.Underline) Then
lblfont.Font = New Font(lblfont.Font,
FontStyle.Italic)
End If


If rtbNote.SelectionFont.Italic And
rtbNote.SelectionFont.Bold And
rtbNote.SelectionFont.Underline Then
lblfont.Font = New Font(lblfont.Font,
FontStyle.Bold Or FontStyle.Underline)
End If
If rtbNote.SelectionFont.Italic And
rtbNote.SelectionFont.Bold And (Not
rtbNote.SelectionFont.Underline) Then
lblfont.Font = New Font(lblfont.Font,
FontStyle.Bold)
End If
If rtbNote.SelectionFont.Italic And (Not
rtbNote.SelectionFont.Bold) And
rtbNote.SelectionFont.Underline Then
lblfont.Font = New Font(lblfont.Font,
FontStyle.Underline)
End If
If rtbNote.SelectionFont.Italic And (Not
rtbNote.SelectionFont.Bold) And (Not
rtbNote.SelectionFont.Underline) Then
lblfont.Font = New Font(lblfont.Font,
FontStyle.Regular)
End If

.

Respuesta Responder a este mensaje
#7 Eduardo A. Morcillo [MS MVP VB]
30/09/2004 - 04:34 | Informe spam
No hace falta que pongas tantos If. Simplemente obten el estilo actual
usando la propiedad Style y modifica el estilo usando OR, AND y XOR. Por
ejemplo:

' El estilo actual mas Bold
Label1.Font = New Font(Label1.Font, Label1.Font.Style Or FontStyle.Bold)

' El estilo actual sin Bold
Label1.Font = New Font(Label1.Font, Label1.Font.Style And Not
FontStyle.Bold)

' Invierto el estado de Bold.
Label1.Font = New Font(Label1.Font, Label1.Font.Style Xor FontStyle.Bold)

Es cuestion de "jugar" con los bits del estilo.

Eduardo A. Morcillo [MS MVP VB]
http://www.mvps.org/emorcillo
email Siga el debate Respuesta Responder a este mensaje
Ads by Google
Help Hacer una pregunta AnteriorRespuesta Tengo una respuesta
Search Busqueda sugerida