lunes, 22 de agosto de 2016

CODIFICACIÓN DE COMBOBOX FUENTE


Imports System.Drawing.Text
Imports System.IO
Public Class Form1
    Private Sub CarregarFont()
        If My.Computer.FileSystem.FileExists(Application.StartupPath & "\font.txt") = False Then
            Dim fi As New System.IO.StreamWriter(Application.StartupPath & "\font.txt")
            Dim family As FontFamily
            For Each family In FontFamily.Families
                If family.IsStyleAvailable(FontStyle.Bold) = False Then Exit For
                fi.WriteLine(family.Name)
            Next family
            fi.Close()
        End If
        '-------------------------------------------------------------------------------------------/
        Dim linha As New StreamReader(Application.StartupPath & "\font.txt")
        Do While Not linha.EndOfStream
            txtFont.Items.Add(linha.ReadLine)
        Loop
        linha.Close()
    End Sub

    Private Sub txtSize_ValueChanged(ByVal sender As Object, ByVal e As EventArgs) Handles txtSize.ValueChanged
        Dim f As New Font(RichTextBox1.SelectionFont.FontFamily, txtSize.Value)
        RichTextBox1.SelectionFont = f
    End Sub
    Private Sub txtFont_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles txtFont.SelectedIndexChanged
        Dim f As New Font(txtFont.Text, RichTextBox1.SelectionFont.Size)
        RichTextBox1.SelectionFont = f
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        CarregarFont()
    End Sub
End Class

0 comentarios:

Publicar un comentario