Click here to Skip to main content
14,934,026 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How would one go about making a notify on a textbox.
when the user enters data in a textbox and clicks save a message box pops up for them to verify the data in the textbox. (Yes,No). If yes is clicked it saves if No they correct the textbox.

Using SQLITE insert statment

What I have tried:

DialogResult dialogResult = MessageBox.Show("Sure", "Please Confirm Your Action", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
Posted
Updated 30-Apr-21 8:54am

Typically, you wouldn't do it for an individual TextBox. You'd VALIDATE the data in the TextBoxes and other controls as required, then show your "Are you sure?" MessageBox when the form is submitted, or clicks a button to make the changes.

You've already done the MessageBox "Are you sure?" thing. It just a matter of validating the data before that MessageBox is shown and actually doing the update afterwards, if the user clicked OK or Yes.
   
Comments
Member 12349103 30-Apr-21 13:37pm
   
I just want them to look at what they entered again, The above code if they select no it stills saves to the database.
Dave Kreskowiak 30-Apr-21 13:43pm
   
If that's the only line of code, then you haven't checked the response to see what it is! You need an if statement after that line to check to see what the response is and then execute code accordingly.
if(MessageBox.Show("Sure", "Please Confirm Your Action", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
     // save
}
else
{
     // inform user ?
}
   
Comments
Member 12349103 30-Apr-21 19:06pm
   
That sill lets them do as will, say No it still saves
BillWoodruff 30-Apr-21 20:01pm
   
You are mistaken: any code inside the first {} will be called only if the user clicks the 'Yes button.
Member 12349103 1-May-21 9:39am
   
You are correct BillWoodruff.
Thanks works great.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900