Click here to Skip to main content
15,901,505 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi guys! I'm wondering how can I hide all the displayed rows in the datagridview when the user clicks the Add New Record button, and display only the blank new row for the user to input data. Any help please? Thanks.
Posted
Comments
Prerak Patel 21-Oct-11 6:24am    
Why do you want to hide those rows?
awmantonio 21-Oct-11 7:03am    
I want to hide it so the user can focus only in entering data in the new row, avoiding unnecessary changes in the current records. Thanks.

1 solution

Off the top of my head, the easiest way would be to use a binding source.

If you set the binding source's criteria to something none of the row's match, then I suppose it would work.

Three other ideas:

First, if you really want to keep a user focused on entering a new record, I would probably consider using a new form specifically designed for data entry.

Second, you could set up some type of validation check on the new row. That way, a user can't switch to an old row until released by the validation check.

Third, you could try overriding the painting of the other rows. It's not going to stop the user from modifying the rows, but if done right will take the focus off.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900