Textbox validation for IP Address in WPF

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-23 12:56:14

问题


I'm making a WPF Application using C#. I want to put validations on integers (0123456789 and ".") only.. The textbox is supposed to contain an IP address... So need to ensure that user key in their correct "IP Address" before they click on the "Submit" button... How can I achieve it?

Thanks.


回答1:


You can easily implement this using Wpf binding validation rules or by using a custom masked textbox

Check these links for exactly what you are looking for

http://geekswithblogs.net/QuandaryPhase/archive/2008/12/17/wpf-masked-textbox.aspx

http://www.switchonthecode.com/tutorials/wpf-tutorial-binding-validation-rules

Hope it helps..




回答2:


The following question link on StackOverflow contains a lot of pointers to MaskedTextBox implementation in WPF. You can use it to get IP Address input from user.

Where can I find a free masked TextBox in WPF?




回答3:


Sounds like you're trying to implement a masked textbox, which is a textbox that auto-format data as the user types according to a specified pattern. Check this tutorial on how to implement this, since is not featured in WPF out-of-the-box: Masked TextBox in WPF



来源:https://stackoverflow.com/questions/4487171/textbox-validation-for-ip-address-in-wpf

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!