Visual Basic - Cambiar estilo del texto a un TextBox

Written by lopezatienza on 29 Octubre 2008 – 11:47 -


Primeramente crearemos un proyecto Application Form.

Le damos el nombre de "ventana" a nuestro formulario.

Crearemos un TextBox llamado "tbintro".

Un CheckBox llamado "cknegrita".

Un CheckBox llamado "cksubrayado".

Un CheckBox llamado "ckrojo".

Introduciremos el siguiente código en nuestro "Form1.vb"

Public Class ventana

 

    Private Sub ckrojo_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ckrojo.CheckedChanged

        tb3.Text = tbintro.Text

 

        If ckrojo.Checked Then

            tb3.Visible = True

            tb2.Visible = False

            tb1.Visible = False

            tbintro.Visible = False

        Else : ckrojo.Checked = False

            tb3.Visible = False

            tb2.Visible = False

            tb1.Visible = False

            tbintro.Visible = True

            'tbintro.Text = tb3.Text

        End If

 

    End Sub

 

    Private Sub cknegrita_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cknegrita.CheckedChanged

        tb1.Text = tbintro.Text

 

        If cknegrita.Checked Then

            tb3.Visible = False

            tb2.Visible = False

            tb1.Visible = True

            tbintro.Visible = False

        Else : cknegrita.Checked = False

            tb3.Visible = False

            tb2.Visible = False

            tb1.Visible = False

            tbintro.Visible = True

           'tbintro.Text = tb1.Text

        End If

    End Sub

 

    Private Sub cksubrayado_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cksubrayado.CheckedChanged

        tb2.Text = tbintro.Text

 

        If cksubrayado.Checked Then

            tb3.Visible = False

            tb2.Visible = True

            tb1.Visible = False

            tbintro.Visible = False

        Else : cksubrayado.Checked = False

            tb3.Visible = False

            tb2.Visible = False

            tb1.Visible = False

            tbintro.Visible = True

           'tbintro.Text = tb2.Text

        End If

    End Sub

End Class


Tags:
Posted in Visual Basic .NET |

Leave a Comment

RSS