In a C# 2010 desktop application that I am modifying, I would like to be able to notify the user that they entered a wrong value in a textbox field. I would like to be able to tell the user the value is incorrect the minute they move the cursor. I would like the error message to be displayed before the user hits the submit button.
Would you show me code to display error message when when cursor position changes?
Loading
datta pawarPosted Jun 18, 2013, 2:37 AM
like
private void textBox1_TextChanged(object sender, EventArgs e)
{
int val = Convert.ToInt16(textBox1.Text);
if (val != 5)
{
MessageBox.Show("Error");
}
}
Pankaj PandeyPosted Jun 18, 2013, 12:40 AM
you can check and show error by using MouseLeave or Leave event.
try this ..
Sie StePosted Jun 17, 2013, 2:21 PM
1. I want to check the values entered to see if the values are valid values in the sql server 2008 r2 database. Can you tell me how this control would come into play in those cases?
2. would i want to use code like lostfocus that is located in the following url: http://msdn.microsoft.com/en-us/library/system.windows.forms.control.lostfocus.aspx?
if so, how would you recommend that I combine the code together?
3. I will also be using the OpenFileDialog class to find a directory path. Can you show me code on how to combine all these items together?
Mahesh ChandPosted Jun 17, 2013, 1:25 PM
http://www.c-sharpcorner.com/UploadFile/scottlysle/UseErrorProvider03082007210138PM/UseErrorProvider.aspx