Hi
I am pretty new to C# and VS2005 so I am sorry if this sounds like a stupid question but;
I am trying to create a messagebox like the one that appears when you attempt to delete something in windows.
Form1 has fields for editing data into an SQL database which works fine from a control within Form1.
I have created a new form (form2) and can get it to display no problem but what I can’t do is get the button on form2 to run the script for deleting the data on form1.
"On form1 user wants to delete data from database, clicks delete, messagebox pops up (form2) 'Are you Sure', user clicks 'yes' form2 disappears, and data is deleted". (This is what I am trying to achieve).
Currently all databinding etc are on form 1.

Help with a 'Delete' MessageBox
Max Diamond
well when you show the message box, check to see what the dialog result is. If its yes, then do your deletion:
if (MessageBox.Show("Are you sure you wish to delete ", "Delete ", MessageBoxButton.YesNo, MessageBox.Icon.Question) == DialogResult.Yes)
{
//user pressed yes. Now do your thing
}
now in regards to deleting a record and the options are on form2, it is advisible to move the delete function to Form2 rather than on the parent form. If you must, you need to have a reference of form1 passed into form2 in order to run the delete command. The delete method must be made public however so the class can access it.
Passing variables:
http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=729974&SiteID=1
To me it seems you are showing just a form (form2) which asks the user if they wish to delete. There is no need to do this since you can achieve this confirmation with a simple MessageBox, as shown above
does this help
RSUser08
Yes it does,
I am actually I am going about it the wrong way.
Thank you.
Edmund
Hi
You can do it like this:
Form1:
Form2:
and THAT'T IT!
Thats all you need to do. Of course you set name and message text and so on, this is minimun.
Your Markku
Ash Dude
Thank you
It is all begining to make sence now!
Cheers