[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Windows Form DataGridView - RowValidating Event Not Firing

Posted on 2009-02-09
4
Medium Priority
?
1,177 Views
Last Modified: 2013-11-26
I'm Developing a Windows Forms application with a datagridview bound to a datasource. In the process of validating some cell values the RowValidating Event does not fire when navagation moves off the row. Works fine moving to Next Row. However, if i change a cell value, Tab back to the left to another cell on the same row, then use the mouse to click on a Previous row above the changed row..... the RowValidating Event does not occur.
Example::
   A B  C D
1 x  x  x  x
2 x  x  x  x
3 x  x  x  x

If I change the value in C2, then backtab (or mouse click) back to B2, Then mouse click on any cell in row 1, the RowValidation Event does not fire and thus the changed value in C2 does not get evaluated. I am manually handling the Datasource Update which is dependant on the validations. Please advise ...
0
Comment
Question by:mpharis
  • 2
  • 2
4 Comments
 
LVL 48

Assisted Solution

by:jpaulino
jpaulino earned 80 total points
ID: 23590458
That's a validation for the row, not for the cells. Use CellValidating event instead
0
 

Author Comment

by:mpharis
ID: 23590577
Therein lies the initial problem. I am using CellValidating but if one cell is dependant on another I cannot navagate away from the invalid cell to change the parent cell controlling the validation logic. Example:
I have both a "Company" column and a "Division" Column. Both columns may have a valid entry for each independent cell but there are only certain valid "Divisions" for a given "Company". I was attempting to use Cell validation for the individual values and then apply RowValidating to ensure the validity of the group "Company and Division".  Otherwise,  a valid company and division would pass the first line of validations and allow the Update of an Invalid Company/Division combination.
I'm open to other approach to this kind of issue?
0
 
LVL 48

Expert Comment

by:jpaulino
ID: 23590872
Can you show what you're doing ?
0
 

Accepted Solution

by:
mpharis earned 0 total points
ID: 23591141
Let me diverge from the intial description to the REAL Issue.
  The idea revolves around a product ID column of an order detail line in a datagridview. I'd like the user to have the option of typing in the product ID or clicking a "Button" in the next column which would display another Gridview (like a Pop-Up) and allow the customer to select the product ID. The concept is to have a button column which the user could click if he/she input the wrong ID and select the Correct One.
   The problem, if the user inputs an invlaid Product ID, CellValidating Fires and prevents the user from navagating away and clicking the Button which would display the valid options to select from. I'm not sure how to handle the scenario so I tried using the RowValidating event for the Product ID to allow for the Button Selection. Sorry for the confusing description. Does what i'm attempting make sense?
Note-I'm using a second datagridview instead of a combobox column in my initial DGV because i what to provide more information for the user to have availble like description, price, Onhand qty, etc..
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses
Course of the Month20 days, 8 hours left to enroll

868 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question