TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
supriya nikam
1.6k
86
4.3k
Text box only allow IP address in windows application
Dec 30 2020 4:49 AM
private void txtSta2_IP_Adrs_KeyUp(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.F1)
{
// Display a pop-up help topic to assist the user.
Help.ShowPopup(txtSta2_IP_Adrs, "enter ip", new Point(txtSta2_IP_Adrs.Right, this.txtSta2_IP_Adrs.Bottom));
}
bool isIPAddress = false;
string pattern = @"\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b";
Regex regex = new Regex(pattern);
isIPAddress = regex.IsMatch(pattern);
//string ip1 = "192.168.0.1";
// string ip2 = "302.0.0.1";
//Regex.IsMatch(ip1, pattern); // returns true
// Regex.IsMatch(ip2, pattern); // returns false
return isIPAddress ;
}
Attachment:
Untitled1.rar
Reply
Answers (
1
)
role authorization in windows form
I am drawing text in panel control, how to save that as images