Click here to Skip to main content
15,896,269 members
Articles / Desktop Programming / Windows Forms

i00 Spell Check and Control Extensions - No Third Party Components Required!

Rate me:
Please Sign up or sign in to vote.
4.95/5 (117 votes)
11 Jan 2014Ms-PL16 min read 1.4M   22   266  
Simple to use, open source Spell Checker for .NET
Imports System.ComponentModel
Imports System.Windows.Forms.Design
Imports System.Drawing.Design  'Must reference System.Design.Dll
Imports System.Globalization

<System.ComponentModel.DesignerCategory("")> _
Public Class AutoGrowLabel
    Inherits BufferedPanel
    Private mc_Text As String
    <System.ComponentModel.Browsable(True), Editor(GetType(System.ComponentModel.Design.MultilineStringEditor), GetType(UITypeEditor))> _
    Public Overrides Property Text() As String
        Get
            Return mc_Text
        End Get
        Set(ByVal value As String)
            If mc_Text <> value Then
                mc_Text = value
                Repaint()
            End If
        End Set
    End Property

    Private Sub AutoGrowLabel_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
        PaintOn(e.Graphics)
    End Sub

    Public Sub PaintOn(ByVal g As Graphics)
        Dim TextSize As Size = TextRenderer.MeasureText(mc_Text, MyBase.Font, New Size(MyBase.Width - Padding.Left - Padding.Right, Integer.MaxValue), TextFormatFlags.WordBreak)
        Me.Height = TextSize.Height + Padding.Bottom + Padding.Top + (Me.Height - Me.ClientSize.Height)
        If g IsNot Nothing Then
            g.FillRectangle(New SolidBrush(Me.BackColor), New Rectangle(0, 0, Me.Width, Me.Height))
            TextRenderer.DrawText(g, mc_Text, MyBase.Font, New Rectangle(Padding.Left, Padding.Top, MyBase.Width - Padding.Left - Padding.Right, Integer.MaxValue), MyBase.ForeColor, TextFormatFlags.WordBreak)
        End If
    End Sub

    Public Sub Repaint()
        MyBase.RaisePaintEvent(Me, New PaintEventArgs(MyBase.CreateGraphics, New Rectangle(0, 0, MyBase.ClientSize.Width, MyBase.ClientSize.Height)))
    End Sub

    Private Sub AutoGrowTextBox_ReRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.TextChanged, Me.FontChanged, Me.PaddingChanged
        Repaint()
    End Sub


    Protected Overrides Sub OnPaddingChanged(ByVal e As System.EventArgs)
        Repaint()
        MyBase.OnPaddingChanged(e)
    End Sub
End Class

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Microsoft Public License (Ms-PL)


Written By
i00
Software Developer (Senior) i00 Productions
Australia Australia
I hope you enjoy my code. It's yours to use for free, but if you do wish to say thank you then a donation is always appreciated.
You can donate here.

Comments and Discussions