Saturday, October 30, 2010

TextBox Control WPF 4.0

I have used the Text Box control quite a lot in my project and I am sure many of you have also used it in your project as It is the basic control which is used to get user input.When reading details about the text box control I have found some of the new things which are in for the WPF 4 text box control and I have never used some of them in my project. Now I will share this with you some of the useful properties of the Text box control.

MultiLine :
    In many application you have used the text box control where you want to enter large in the text box control like the description is one of the example. For this case user can enter text in the text box control in multiple line. So in order to allow multiple line support use property AcceptsReturn which is used to entered the Enter key.

Image 1

TextBox always supports multiple lines of text programmatically. If  string which is assigned to the Text property of the text box containing NewLine characters like \n in C#, it displays the multiple lines regardless of the value of AcceptsReturn. Also, the multiline support is completely independent from text wrapping. Text wrapping applies only to individual lines of text that are wider than the TextBox.


Spell Checking :
         Spell checking can be enabled on the text box control by setting the SpellCheck.IsEnabled to true. When you set the SpellChek.IsEnabed to true then text box control will automatically detect the wrong word and underlined these words with red line as see in the Image 2, the similar kind of behavior you have seen while typing in the Microsoft Word. Now as you  have experience it  in Microsoft Word that you can right click on the red underlined word and it will give you suggestions of the word in list box. From the list of the suggested option for the wrong word you can choose the correct word.

Image 2

In the Image 2 you can see that I have entered wrong words like wrog entere and TextBox. You can place mouse on any of the word and select the correct word from the suggestion which are appears by right clicking on the word

All and any comments / bugs / suggestions are welcomed!


1 comment:

Anonymous said...

none of this is new; both of these properties/features have been available since WPF 1.0