We help IT Professionals succeed at work.

Are u sure u want to delete row?

mathieu_cupryk
on
Medium Priority
260 Views
Last Modified: 2010-04-16
I need a message box asking the user if he wants to delete row?
Comment
Watch Question

CERTIFIED EXPERT

Commented:
can u be more specific how do the user delete the row ?
CERTIFIED EXPERT

Commented:
by using the delete key in the grid (it's a grid rt)

or by using some button in the form ?
CERTIFIED EXPERT
Commented:
u could trap the delete key press in the grid in the grid key down..like


//hook event in constructor
AGrdi.KeyDown += new System.Windows.Forms.KeyEventHandler(AGrdi_KeyDown);




private static void AGrdi_KeyDown(object sender
                  , System.Windows.Forms.KeyEventArgs e)
            {
                  if(e.KeyCode == System.Windows.Forms.Keys.Delete)
                  {
                        System.Windows.Forms.DialogResult Result =
                              System.Windows.Forms.MessageBox.Show
                              ("Question","Mesage Caption",System.Windows.Forms.MessageBoxButtons.YesNo
                              ,System.Windows.Forms.MessageBoxIcon.Question);
                        if(Result == System.Windows.Forms.DialogResult.Yes)
                        {
                              //Delete Logic
                        }
                              
                  }
            }

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
anyoneisSoftware Developer
Top Expert 2006

Commented:
If you are using a DataGridView, set AllowUserToDeleteRows False, and provide a button to delete the selected grid row.

David
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.