I have make connection with the Access DB in Visual C# 2005 everything is ok and working great. The wizard has make and toolbar for adding deleting data and saving.So my question is how i can make now when the user click on let say want to delete data show the confirmation dialog for deleting because now when you click on deleting the data is delete with out asking. I want to do this because some times we can click on some data that we don't want to delete or in mistake we select the data that how i have say don't want to delete.

I'm waiting the answers, pls help.

Thanks

Recommended Answers

All 9 Replies

put this in the event handler for the delete button:

if (MessageBox.Show("Deleting data", "are you sure you want to delete the data?", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
    //delete the data
}
commented: Here's some free +rep to give ya some rep-altering power.. :) +12

I have try to find the event handler but i can't because the wizard has create own BindingNavigator and put by own Delete button. When i select button and go to events for that button is not showing some event for that button but is working delete data???

How to find?

Thanks,

May I ask how you accessed this wizard?

i go to Data Sources window and from there i have crate New Data Source and i have folow the steps. On the end with drag and drop from the Data Source Window i have put on the form and has create a DataGrid View and binding navigator how i have say where has buttons for navigations, for adding new data, deleting and saving. That is i have done and if i have not mentioned i work in Visual C# 2005

Thanks,

I have observed that the delete button doesn't actually permanently delete the record. Perhaps this in an indication that you must ocde this behavior yourself?

i have see all poseblle combination and try at. I have add some new data Save and i have check the Access DB open and is ok. Then i have delete the same data open once again the DB and the data was deleted. But another interesting thing that i have saw.For the save button has a Event and the code for that Event is in the Form1.cs.

here is the code that is generated in Form1

namespace testSifraBaza
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void tblDetalnaBindingNavigatorSaveItem_Click(object sender, EventArgs e)
        {
            this.Validate();
            this.tblDetalnaBindingSource.EndEdit();
            this.tblDetalnaTableAdapter.Update(this.dsCelosna.tblDetalna);

        }

        private void Form1_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'dsCelosna.tblDetalna' table. You can move, or remove it, as needed.
            this.tblDetalnaTableAdapter.Fill(this.dsCelosna.tblDetalna);

        }



   
    }
}

i have see all poseblle combination and try at. I have add some new data Save and i have check the Access DB open and is ok. Then i have delete the same data open once again the DB and the data was deleted. But another interesting thing that i have saw.For the save button has a Event and the code for that Event is in the Form1.cs.

here is the code that is generated in Form1

namespace testSifraBaza
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void tblDetalnaBindingNavigatorSaveItem_Click(object sender, EventArgs e)
        {
            this.Validate();
            this.tblDetalnaBindingSource.EndEdit();
            this.tblDetalnaTableAdapter.Update(this.dsCelosna.tblDetalna);

        }

        private void Form1_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'dsCelosna.tblDetalna' table. You can move, or remove it, as needed.
            this.tblDetalnaTableAdapter.Fill(this.dsCelosna.tblDetalna);

        }



   
    }
}

Try see if this.tblDetalnaBindingSource.CancelEdit() will stop it from deleting.

Thanks man a lot for the help i solve the problem!!! :)

I put the new button for Deleting and now is working. Once again thanks for the ideas and for the link!!!

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.