From the course: Windows Presentation Foundation 5: Interaction and Controls

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

The TextBox Changed events

The TextBox Changed events

From the course: Windows Presentation Foundation 5: Interaction and Controls

Start my 1-month free trial

The TextBox Changed events

- [Instructor] The text box supports two changed events that let you know when the user has changed something in the text. They are the selection changed and the text change. I'll start by looking at the selection change. It's a simple concept to understand. Here I've set on this text box, I specified a selection changed event handler. The code is simple. At the beginning of the method is some air checking to make sure there is something selected, and if there is, then I grab the selected text and echo it back to the screen. It look like this. Double click on the word inspired, and that word appears here in the second text block down here. It doesn't matter how I select the items. I can double click, I can use my mouse, I can drag like this, I'll show you how to drag here. That selects a few characters, that selects a few more, you get the idea. So it's a quick way of discovering when the user has selected words in the text box so you can perform some action. You can also get an event…

Contents