Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. DataGridViewDataErrorContexts problem

DataGridViewDataErrorContexts problem

Scheduled Pinned Locked Moved C#
helpquestionjson
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    eyalle
    wrote on last edited by
    #1

    Can anybody explain to me how I handle the DataError Event? I have the following code but the error does not get picked up by any of them. Looking at e.Context shows " Parsing | Commit | CurrentCellChange ", how do I get the individual values? if (e.Context == DataGridViewDataErrorContexts.Commit) { MessageBox.Show("Commit error"); } if (e.Context == DataGridViewDataErrorContexts.CurrentCellChange) { MessageBox.Show("Cell change"); } if (e.Context == DataGridViewDataErrorContexts.Parsing) { MessageBox.Show("parsing error"); } if (e.Context == DataGridViewDataErrorContexts.LeaveControl) { MessageBox.Show("leave control error"); }

    L 1 Reply Last reply
    0
    • E eyalle

      Can anybody explain to me how I handle the DataError Event? I have the following code but the error does not get picked up by any of them. Looking at e.Context shows " Parsing | Commit | CurrentCellChange ", how do I get the individual values? if (e.Context == DataGridViewDataErrorContexts.Commit) { MessageBox.Show("Commit error"); } if (e.Context == DataGridViewDataErrorContexts.CurrentCellChange) { MessageBox.Show("Cell change"); } if (e.Context == DataGridViewDataErrorContexts.Parsing) { MessageBox.Show("parsing error"); } if (e.Context == DataGridViewDataErrorContexts.LeaveControl) { MessageBox.Show("leave control error"); }

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      Hi, DataGridViewDataErrorContexts is an enum and has the FlagsAttribute, which means all members are really bit-oriented flags, so try this:

      if ((e.Context & DataGridViewDataErrorContexts.Parsing)!=0) {
      MessageBox.Show("parsing error");
      }

      PS: please use PRE tags to show code, as I did (see the difference?) :)

      Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


      I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that.


      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups