Setting a Control Property Value from a Non-UI Thread

As most of you might know (I hope) it is unwise to call methods on a Control from a non-UI thread. This can cause all sorts of issues. Actually, I think in most cases .NET will throw and Exception. If you need to set a property on a Control this is how you would properly … Continue reading Setting a Control Property Value from a Non-UI Thread

Convert RTF to Text

If you need to convert RTF to text, here is a simple way of doing it:    Public Shared Function ConvertRtfToText(ByVal input As String) As String      Dim returnValue As String = String.Empty      Using converter As New System.Windows.Forms.RichTextBox()        converter.Rtf = input        returnValue = converter.Text      End Using      Return returnValue    End Function Tip Submitted By: David McCarter This code … Continue reading Convert RTF to Text

Ignoring Characters in a TexBox

The code below shows you how to ignore all input unless it's a number:private void searchText_KeyPress(object sender, KeyPressEventArgs e){ if (e.KeyChar != 8) {  if (char.IsNumber(e.KeyChar) == false)  {   e.Handled = true; }} I allow the backspace keypress by checking for character 8. You can easily modify this code to suit your needs.   Tip Submitted By: David McCarter