| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | ||||
| 4 | 5 | 6 | 7 | 8 | 9 | 10 |
| 11 | 12 | 13 | 14 | 15 | 16 | 17 |
| 18 | 19 | 20 | 21 | 22 | 23 | 24 |
| 25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- chashtag
- programmers
- convert
- Coding
- IValueConverter
- windows
- coding-test
- Github
- C#
- log
- 코딩테스트
- Process
- git
- logging
- Binding
- Microsoft
- windows10
- algorithm
- Visual Studio
- mysql
- nullable
- commit
- ListView
- WPF
- dotNET
- string
- csharp
- File
- tls
- .net
Archives
- Today
- Total
목록PreviewTextInput (1)
CHashtag
안녕하세요. 오늘은 WPF에서 TextBox를 사용할 때 숫자만 입력받는 방법에 대해 알아보도록 하겠습니다. 방법이 간단하여 바로 코드로 설명해드리도록 하겠습니다. PreviewTextInput Event는 Text가 변경되었을 때 값이 반영되기 전에 먼저 들어오는 이벤트입니다. 여기서 e.Handled값을 이용하여 값 변경을 허용할지 말지를 결정짓게 되는겁니다. 따라서 Regex를 이용하여 숫자일 때에만 수정이 가능하게 구현하였습니다. // MainWindow.xaml.cs using System.Text.RegularExpressions; private void TextBox_PreviewTextInput(object sender, TextCompositionEventArgs e) { Regex re..
C#/WPF
2021. 11. 29. 22:38