Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

how to write my own Exception.Message of DataError event according to the control of cellvalidating

$
0
0

hi

   i'd like to ask, in DataError event ,i want to write my own message. For example,in cellvalidating I want write some of my own message, and in  DataError i can display them with a messgaebox

   Or, i want to say "in cellvalidating event, I can"throw" some special exception for DataError Event".I dont know whether I should throw a new exception or not. as we know, for DataError event they provide some type of DataGridViewDataErrorEventArgs.Exception.Message, I just would like that,in cellvalidating event,I can "cutomize" the DataGridViewDataErrorEventArgs.Exception.Message

  i'd like to explain one thing, for example, for dataError event it has it's errormessage,for example, when there is a string value for int column, but my validating event will have a control to make messgaebox.show,too,with my own message. in this case, in runtime the users will has 2 messagebox at one time.thats not good. but i still need DataError event to catch some errores.

some thing like

  

privatevoid dataGridView1_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)        {            if (e.FormattedValue.ToString() == "aa")            {                //wrtie a special frase such as "you can not input aa according to the regular"            }

}

 private void dataGridView1_DataError(object sender, DataGridViewDataErrorEventArgs e)        {           //MessageBox.show "you can not input aa according to the regular"             e.Cancel = true;         }

 




Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>