dataGridView default error dialog handle












0














I am trying to hide default datagridview error dialog.
I put in the code this event handler:



        this.dataGridView2.DataError += new System.Windows.Forms.DataGridViewDataErrorEventHandler(dataGridView2_DataError);


private void dataGridView2_DataError(object sender, DataGridViewDataErrorEventArgs e)
{
//empty so it doesn't show anything
}


But still when i try this and leave datagridview cell empty ( delete everything from it), it show me dialog box with error.



Screenshot of error:



enter image description here










share|improve this question




















  • 1




    Can we assume that you get your names right and have indeed hooked up one event to both DGVs?
    – TaW
    Jun 12 '16 at 17:39










  • @TaW Oh I missed it, and banging my head why it isn't hiding the dialog..
    – Shaharyar
    Jun 12 '16 at 17:40










  • Oh i get it now. I hooked event on dgv1 and was testing it on dgv2. Thanks.
    – DoLoop
    Jun 13 '16 at 7:15
















0














I am trying to hide default datagridview error dialog.
I put in the code this event handler:



        this.dataGridView2.DataError += new System.Windows.Forms.DataGridViewDataErrorEventHandler(dataGridView2_DataError);


private void dataGridView2_DataError(object sender, DataGridViewDataErrorEventArgs e)
{
//empty so it doesn't show anything
}


But still when i try this and leave datagridview cell empty ( delete everything from it), it show me dialog box with error.



Screenshot of error:



enter image description here










share|improve this question




















  • 1




    Can we assume that you get your names right and have indeed hooked up one event to both DGVs?
    – TaW
    Jun 12 '16 at 17:39










  • @TaW Oh I missed it, and banging my head why it isn't hiding the dialog..
    – Shaharyar
    Jun 12 '16 at 17:40










  • Oh i get it now. I hooked event on dgv1 and was testing it on dgv2. Thanks.
    – DoLoop
    Jun 13 '16 at 7:15














0












0








0







I am trying to hide default datagridview error dialog.
I put in the code this event handler:



        this.dataGridView2.DataError += new System.Windows.Forms.DataGridViewDataErrorEventHandler(dataGridView2_DataError);


private void dataGridView2_DataError(object sender, DataGridViewDataErrorEventArgs e)
{
//empty so it doesn't show anything
}


But still when i try this and leave datagridview cell empty ( delete everything from it), it show me dialog box with error.



Screenshot of error:



enter image description here










share|improve this question















I am trying to hide default datagridview error dialog.
I put in the code this event handler:



        this.dataGridView2.DataError += new System.Windows.Forms.DataGridViewDataErrorEventHandler(dataGridView2_DataError);


private void dataGridView2_DataError(object sender, DataGridViewDataErrorEventArgs e)
{
//empty so it doesn't show anything
}


But still when i try this and leave datagridview cell empty ( delete everything from it), it show me dialog box with error.



Screenshot of error:



enter image description here







c# datagridview






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jun 13 '16 at 7:15

























asked Jun 12 '16 at 16:58









DoLoop

6018




6018








  • 1




    Can we assume that you get your names right and have indeed hooked up one event to both DGVs?
    – TaW
    Jun 12 '16 at 17:39










  • @TaW Oh I missed it, and banging my head why it isn't hiding the dialog..
    – Shaharyar
    Jun 12 '16 at 17:40










  • Oh i get it now. I hooked event on dgv1 and was testing it on dgv2. Thanks.
    – DoLoop
    Jun 13 '16 at 7:15














  • 1




    Can we assume that you get your names right and have indeed hooked up one event to both DGVs?
    – TaW
    Jun 12 '16 at 17:39










  • @TaW Oh I missed it, and banging my head why it isn't hiding the dialog..
    – Shaharyar
    Jun 12 '16 at 17:40










  • Oh i get it now. I hooked event on dgv1 and was testing it on dgv2. Thanks.
    – DoLoop
    Jun 13 '16 at 7:15








1




1




Can we assume that you get your names right and have indeed hooked up one event to both DGVs?
– TaW
Jun 12 '16 at 17:39




Can we assume that you get your names right and have indeed hooked up one event to both DGVs?
– TaW
Jun 12 '16 at 17:39












@TaW Oh I missed it, and banging my head why it isn't hiding the dialog..
– Shaharyar
Jun 12 '16 at 17:40




@TaW Oh I missed it, and banging my head why it isn't hiding the dialog..
– Shaharyar
Jun 12 '16 at 17:40












Oh i get it now. I hooked event on dgv1 and was testing it on dgv2. Thanks.
– DoLoop
Jun 13 '16 at 7:15




Oh i get it now. I hooked event on dgv1 and was testing it on dgv2. Thanks.
– DoLoop
Jun 13 '16 at 7:15












3 Answers
3






active

oldest

votes


















3














Try to Handle and Cancel the event:



private void dataGridView2_DataError(object sender, DataGridViewDataErrorEventArgs e)
{
e.Cancel = true;
}





share|improve this answer





















  • Still the same. DataGridView default dialog still shows.
    – DoLoop
    Jun 12 '16 at 17:11










  • Can you attach a screenshot?
    – Shaharyar
    Jun 12 '16 at 17:12










  • Edited. Look up.
    – DoLoop
    Jun 12 '16 at 17:19










  • @DoLoop How many GridView do you have? Are you subscribing all of them to this event?
    – Shaharyar
    Jun 12 '16 at 17:41










  • In that form 2, 1 i am using and 1 for test (datagridview2)
    – DoLoop
    Jun 13 '16 at 7:12



















1














try to use this code to handle the event:



private void dataGridView2_DataError(object sender, DataGridViewDataErrorEventArgs e)
{
e.Cancel = true;
}





share|improve this answer































    0














    Try the next code , it's work!



     private void dataGridView1_DataError(object sender, DataGridViewDataErrorEventArgs e)
    {
    try
    {
    //To handle 'ConstraintException' default error dialog (for example, unique value)
    if ((e.Exception) is ConstraintException)
    {
    // ErrorText glyphs show
    view.Rows[e.RowIndex].ErrorText = "must be unique value";
    view.Rows[e.RowIndex].Cells[e.ColumnIndex].ErrorText = "must be unique value";

    //...or MessageBox show
    MessageBox.Show(e.Exception.Message, "Error ConstraintException",
    MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
    //Suppress a ConstraintException
    e.ThrowException = false;
    }
    }
    catch (Exception ex)
    {
    MessageBox.Show(ex.Message, "ERROR: dataGridView1_DataError",
    MessageBoxButtons.OK, MessageBoxIcon.Error);
    }
    }





    share|improve this answer





















      Your Answer






      StackExchange.ifUsing("editor", function () {
      StackExchange.using("externalEditor", function () {
      StackExchange.using("snippets", function () {
      StackExchange.snippets.init();
      });
      });
      }, "code-snippets");

      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "1"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f37776854%2fdatagridview-default-error-dialog-handle%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      3














      Try to Handle and Cancel the event:



      private void dataGridView2_DataError(object sender, DataGridViewDataErrorEventArgs e)
      {
      e.Cancel = true;
      }





      share|improve this answer





















      • Still the same. DataGridView default dialog still shows.
        – DoLoop
        Jun 12 '16 at 17:11










      • Can you attach a screenshot?
        – Shaharyar
        Jun 12 '16 at 17:12










      • Edited. Look up.
        – DoLoop
        Jun 12 '16 at 17:19










      • @DoLoop How many GridView do you have? Are you subscribing all of them to this event?
        – Shaharyar
        Jun 12 '16 at 17:41










      • In that form 2, 1 i am using and 1 for test (datagridview2)
        – DoLoop
        Jun 13 '16 at 7:12
















      3














      Try to Handle and Cancel the event:



      private void dataGridView2_DataError(object sender, DataGridViewDataErrorEventArgs e)
      {
      e.Cancel = true;
      }





      share|improve this answer





















      • Still the same. DataGridView default dialog still shows.
        – DoLoop
        Jun 12 '16 at 17:11










      • Can you attach a screenshot?
        – Shaharyar
        Jun 12 '16 at 17:12










      • Edited. Look up.
        – DoLoop
        Jun 12 '16 at 17:19










      • @DoLoop How many GridView do you have? Are you subscribing all of them to this event?
        – Shaharyar
        Jun 12 '16 at 17:41










      • In that form 2, 1 i am using and 1 for test (datagridview2)
        – DoLoop
        Jun 13 '16 at 7:12














      3












      3








      3






      Try to Handle and Cancel the event:



      private void dataGridView2_DataError(object sender, DataGridViewDataErrorEventArgs e)
      {
      e.Cancel = true;
      }





      share|improve this answer












      Try to Handle and Cancel the event:



      private void dataGridView2_DataError(object sender, DataGridViewDataErrorEventArgs e)
      {
      e.Cancel = true;
      }






      share|improve this answer












      share|improve this answer



      share|improve this answer










      answered Jun 12 '16 at 17:06









      Shaharyar

      9,71522848




      9,71522848












      • Still the same. DataGridView default dialog still shows.
        – DoLoop
        Jun 12 '16 at 17:11










      • Can you attach a screenshot?
        – Shaharyar
        Jun 12 '16 at 17:12










      • Edited. Look up.
        – DoLoop
        Jun 12 '16 at 17:19










      • @DoLoop How many GridView do you have? Are you subscribing all of them to this event?
        – Shaharyar
        Jun 12 '16 at 17:41










      • In that form 2, 1 i am using and 1 for test (datagridview2)
        – DoLoop
        Jun 13 '16 at 7:12


















      • Still the same. DataGridView default dialog still shows.
        – DoLoop
        Jun 12 '16 at 17:11










      • Can you attach a screenshot?
        – Shaharyar
        Jun 12 '16 at 17:12










      • Edited. Look up.
        – DoLoop
        Jun 12 '16 at 17:19










      • @DoLoop How many GridView do you have? Are you subscribing all of them to this event?
        – Shaharyar
        Jun 12 '16 at 17:41










      • In that form 2, 1 i am using and 1 for test (datagridview2)
        – DoLoop
        Jun 13 '16 at 7:12
















      Still the same. DataGridView default dialog still shows.
      – DoLoop
      Jun 12 '16 at 17:11




      Still the same. DataGridView default dialog still shows.
      – DoLoop
      Jun 12 '16 at 17:11












      Can you attach a screenshot?
      – Shaharyar
      Jun 12 '16 at 17:12




      Can you attach a screenshot?
      – Shaharyar
      Jun 12 '16 at 17:12












      Edited. Look up.
      – DoLoop
      Jun 12 '16 at 17:19




      Edited. Look up.
      – DoLoop
      Jun 12 '16 at 17:19












      @DoLoop How many GridView do you have? Are you subscribing all of them to this event?
      – Shaharyar
      Jun 12 '16 at 17:41




      @DoLoop How many GridView do you have? Are you subscribing all of them to this event?
      – Shaharyar
      Jun 12 '16 at 17:41












      In that form 2, 1 i am using and 1 for test (datagridview2)
      – DoLoop
      Jun 13 '16 at 7:12




      In that form 2, 1 i am using and 1 for test (datagridview2)
      – DoLoop
      Jun 13 '16 at 7:12













      1














      try to use this code to handle the event:



      private void dataGridView2_DataError(object sender, DataGridViewDataErrorEventArgs e)
      {
      e.Cancel = true;
      }





      share|improve this answer




























        1














        try to use this code to handle the event:



        private void dataGridView2_DataError(object sender, DataGridViewDataErrorEventArgs e)
        {
        e.Cancel = true;
        }





        share|improve this answer


























          1












          1








          1






          try to use this code to handle the event:



          private void dataGridView2_DataError(object sender, DataGridViewDataErrorEventArgs e)
          {
          e.Cancel = true;
          }





          share|improve this answer














          try to use this code to handle the event:



          private void dataGridView2_DataError(object sender, DataGridViewDataErrorEventArgs e)
          {
          e.Cancel = true;
          }






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Jun 22 '16 at 6:59









          Draken

          2,56382540




          2,56382540










          answered Jun 12 '16 at 17:15









          Mohsen Karimi

          111




          111























              0














              Try the next code , it's work!



               private void dataGridView1_DataError(object sender, DataGridViewDataErrorEventArgs e)
              {
              try
              {
              //To handle 'ConstraintException' default error dialog (for example, unique value)
              if ((e.Exception) is ConstraintException)
              {
              // ErrorText glyphs show
              view.Rows[e.RowIndex].ErrorText = "must be unique value";
              view.Rows[e.RowIndex].Cells[e.ColumnIndex].ErrorText = "must be unique value";

              //...or MessageBox show
              MessageBox.Show(e.Exception.Message, "Error ConstraintException",
              MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
              //Suppress a ConstraintException
              e.ThrowException = false;
              }
              }
              catch (Exception ex)
              {
              MessageBox.Show(ex.Message, "ERROR: dataGridView1_DataError",
              MessageBoxButtons.OK, MessageBoxIcon.Error);
              }
              }





              share|improve this answer


























                0














                Try the next code , it's work!



                 private void dataGridView1_DataError(object sender, DataGridViewDataErrorEventArgs e)
                {
                try
                {
                //To handle 'ConstraintException' default error dialog (for example, unique value)
                if ((e.Exception) is ConstraintException)
                {
                // ErrorText glyphs show
                view.Rows[e.RowIndex].ErrorText = "must be unique value";
                view.Rows[e.RowIndex].Cells[e.ColumnIndex].ErrorText = "must be unique value";

                //...or MessageBox show
                MessageBox.Show(e.Exception.Message, "Error ConstraintException",
                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                //Suppress a ConstraintException
                e.ThrowException = false;
                }
                }
                catch (Exception ex)
                {
                MessageBox.Show(ex.Message, "ERROR: dataGridView1_DataError",
                MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                }





                share|improve this answer
























                  0












                  0








                  0






                  Try the next code , it's work!



                   private void dataGridView1_DataError(object sender, DataGridViewDataErrorEventArgs e)
                  {
                  try
                  {
                  //To handle 'ConstraintException' default error dialog (for example, unique value)
                  if ((e.Exception) is ConstraintException)
                  {
                  // ErrorText glyphs show
                  view.Rows[e.RowIndex].ErrorText = "must be unique value";
                  view.Rows[e.RowIndex].Cells[e.ColumnIndex].ErrorText = "must be unique value";

                  //...or MessageBox show
                  MessageBox.Show(e.Exception.Message, "Error ConstraintException",
                  MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                  //Suppress a ConstraintException
                  e.ThrowException = false;
                  }
                  }
                  catch (Exception ex)
                  {
                  MessageBox.Show(ex.Message, "ERROR: dataGridView1_DataError",
                  MessageBoxButtons.OK, MessageBoxIcon.Error);
                  }
                  }





                  share|improve this answer












                  Try the next code , it's work!



                   private void dataGridView1_DataError(object sender, DataGridViewDataErrorEventArgs e)
                  {
                  try
                  {
                  //To handle 'ConstraintException' default error dialog (for example, unique value)
                  if ((e.Exception) is ConstraintException)
                  {
                  // ErrorText glyphs show
                  view.Rows[e.RowIndex].ErrorText = "must be unique value";
                  view.Rows[e.RowIndex].Cells[e.ColumnIndex].ErrorText = "must be unique value";

                  //...or MessageBox show
                  MessageBox.Show(e.Exception.Message, "Error ConstraintException",
                  MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                  //Suppress a ConstraintException
                  e.ThrowException = false;
                  }
                  }
                  catch (Exception ex)
                  {
                  MessageBox.Show(ex.Message, "ERROR: dataGridView1_DataError",
                  MessageBoxButtons.OK, MessageBoxIcon.Error);
                  }
                  }






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 23 at 8:42









                  kammer

                  1




                  1






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.





                      Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                      Please pay close attention to the following guidance:


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f37776854%2fdatagridview-default-error-dialog-handle%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Contact image not getting when fetch all contact list from iPhone by CNContact

                      count number of partitions of a set with n elements into k subsets

                      A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks