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
Behrouz Hosseini
NA
72
0
How to Restrict Textbox Input in Hexadecimal Range
Oct 22 2011 6:12 PM
Hi,
Can you please take a look at following code and let me know how I can restrict the "txtColor.Text" in a way that if user insert a wrong hex sting(value) like "KKKKKK" the exception handler handle the issue and pops a warning message to correct the input?
Here is the code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace SimpleColorPicker
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void txtColor_TextChanged(object sender, EventArgs e)
{
if (txtColor.Text == "")
{
lblColor.ForeColor = System.Drawing.Color.MediumPurple;
}
else
{
string cc = String.Format("#{0}", txtColor.Text);
Color col = System.Drawing.ColorTranslator.FromHtml(cc);
lblColor.ForeColor = col;
lblColor.Refresh();
}
}
}
}
Thanks,
Reply
Answers (
2
)
create console application in monodevelop
Crystal Reports