How to Differentiate Two Cell Values in DataGridView Control

Submitted by: 
Visitors have accessed this post 6928 times.
I read a lot of question about this on the forum and thought it’s time to share with you on how to differentiate two cell values in DataGridView control. By default we use the Value property of cells like:
  1. QtyOrdered = InvoiceDetails("Qty", e.RowIndex).Value
Another is to use the FormattedValue like:
  1. QtyOrdered = InvoiceDetails("Qty ", e.RowIndex).FormattedValue
But the two code above will not work if you have a condition like
  1. If QtyOrdered > InvoiceDetails ("TotalQty", e.RowIndex).Value Then
to determine if the Qty Ordered is less than the Qty in your inventory. The solution to this problem is to use the EditedFormattedValue like:
  1. QtyOrdered = InvoiceDetails("Qty", e.RowIndex).EditedFormattedValue
EditedFormattedValue property is useful if you want to differentiate the value using DataGridView. CellValidating Event

Comments

hello, may i please have the password such that i can get alook at your database...

email me at [email protected]

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • You may insert videos with [video:URL]
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <th> <img> <h1> <h2> <h3> <iframe> [video]
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <asp>, <c>, <cpp>, <csharp>, <css>, <html4strict>, <java>, <javascript>, <mysql>, <php>, <python>, <sql>, <vb>, <vbnet>. The supported tag styles are: <foo>, [foo].
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.