Asfand Iqbal

Asfand Iqbal

  • NA
  • 24
  • 2.8k

DataGridView RowValidating e.Cancel locks user input.

Apr 25 2018 8:12 AM

Hi All,

It is evident that this website is geared around c#, however, the issue I am encountering is written in Vb.Net and I hope your expertise will help us to resolve this issue.

We are working on this small .Net WinForms application and validates the contents of the Data grid.

During the validation process the business related rules are applied in the "RowValidating" event of the data grid, where we set the ErrorText property of the DataGridViewRow object, which displays the error icon along with the text we set so user can hover this icon to get error details.

However, when the error is set then user is unable to enter any data in any of the textbox (Either displayed on the same Form or if we open a new Form). At this stage we can open other Forms too but user cannot put any text or choose values from dropdown combo boxes. User can only able to enter input once the error of the Data Grid View is resolved (i.e. user fills the required columns etc.)

We have upload the sample code (not like the acutal application, however, the underlying concept is same). Please follow the following steps to reproduce the issue.
  • When you first run the application; you will see two icons "Products and Customer".

    - Click on "Products" button and it will display the DataGrid, enter Product Name and move to next line (2nd line)
    - This will display the error notification in the Row as the validation rule forces you to enter a value in the "Order %" or "Order Amount".
    - At this stage; please click on the second toolbar button "Customers" which will display the "Customers" Form.
    - Now if you try to click the text box then you won't be able to do this because the "Products" data grid is in error state.
    - Now you cannot do anything until you fix the error of the DataGrid. 

https://ufile.io/iwmgh
 
You can download the source by opening the above File share website or please see attached zip file.
 
Looking forward to see how this can be resolved. Thanks.

Answers (2)