WinForm Properties to disable Adding and Deleting records

I'm using VB.Net 2005 and I am trying to do the following on a WinForm;  When form loads, based on who is logged in, I want to enable or disable the user's ability to add and delete records.  The form has fields on the main form and also a datagridview.  I also need to be able to detect if the form is dirty (i.e. has records edited)

Question:
1.  What is the code to prevent adding/deleting records on main form and on the DataGridView?
2.  How do I determine if the Form is Dirty?
KentDBerryAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jorge PaulinoIT Pro/DeveloperCommented:
>> 1.  What is the code to prevent adding/deleting records on main form and on the DataGridView?
You can set the controls to readonly. In the DataGridView you can set to false the following properties AllowUserToAddRows, AllowUserToDeleteRows and readonly


>>2.  How do I determine if the Form is Dirty?
Don't understand this question
0
KentDBerryAuthor Commented:
I'm basically trying to simulate some things in access which had a property .Dirty that got set to True if a particular record has been edited.

I do want people to be able to edit existing records, so my #1 above needs some sort of technique to detect if the pointer is on a new record or if the user is trying to delete an existing record.
0
Jorge PaulinoIT Pro/DeveloperCommented:
Well DataGridView are bind to a dataset. When you change the bind datagridview you will be changing the dataset and you can check if the dataset as changes this way:

If MyDataSet.HasChanges Then
   MessageBox.Show("Datagridview changed!")
End If
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
KentDBerryAuthor Commented:
Thank you.
0
Jorge PaulinoIT Pro/DeveloperCommented:
Glad I could help!

jpaulino
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.