hi,
i want to write code on validation of text box , combo box
for make them not null fields,
And other for mae a text box only accept integer , one only accept string not integer value.
so pls. tell me where shud i write dis code & give me some examples of code
kool.net
0
Light Poster
Recommended Answers
Jump to PostTry something like this:
private void btnAdd_Click(object sender, EventArgs e) { //Must be an integer int scoreInput; if (string.IsNullOrEmpty(txtScore.Text) || !int.TryParse(txtScore.Text, out scoreInput)) { txtScore.Focus(); MessageBox.Show("Please enter a valid score", "Input Error"); txtScore.Focus(); //in case they double click the message and select another ctrl return; } else …
Jump to PostHere is an example of capturing the KeyDown and KeyPress events for a textbox to limit numeric input. You could also modify this logic to accept only the characters you want: Limiting input …
All 7 Replies
coder4Ever
0
Newbie Poster
sknake
1,622
Senior Poster
Featured Poster
DdoubleD
315
Posting Shark
mikiurban
16
Junior Poster in Training
kool.net
0
Light Poster
avirag
10
Posting Whiz
avirag
10
Posting Whiz
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.