How to see if a cell has changed in datagridview

visual basic 2010

I have a datagridview that is bound to a datatable in a book purchasing program I'm working on. I would like to change one field (Vendor) if the user changes another field (Price). Basically the datagridview is populated with the title information and price from one of several wholesalers and if the user changes the price, I want the Vendor field on that record to change to "Custom."

There are only going to be 10 or so records in the datagridview at a time so looping through won't be a problem. I'm just not sure how to see if a specific cell versus the whole row has changed (the user will be making other changes such as quantity that don't require setting the vendor to custom) and then how to change the Vendor field for that row.
berniesbooksAsked:
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.

sdrouinsCommented:
did you try with
DataGridView.CellValueChanged Event
0
berniesbooksAuthor Commented:
With CellValueChanged, how do I tell it to run the event only when the "Price" cell is changed? The user needs to be able to make changes to some of the other cells without triggering the event.
0
CodeCruiserCommented:
Use boolean flags and set them in the CellValueChanged event if its the cell you are interested in.
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

gamarrojgqCommented:
Hi,

This event is trigger for every cell, so, in the CellValueChanged event you have the e parameter, As System.Windows.Forms.DataGridViewCellEventArgs, this have a ColumnIndex  property that let you know wich cell was changed, so you can valid this to see if is  equal to your Price columnindex and if is different, you just can exit the event.

Hope it helps.
0
berniesbooksAuthor Commented:
I apologize, this is my first project working with datagridview. CodeCruiser can you point me to a code sample that sets the boolean flag and then references it in the event?
0
CodeCruiserCommented:
In the CellValueChanged Event

If e.ColumnIndex = 2 Then 'This assumes that the cell you are interested in is at 3rd position
   'Modify the other value here
   'datagridview1.Rows(e.RowIndex).Cells(1).Value = "new value"
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
berniesbooksAuthor Commented:
Thanks CodeCruiser!

It's a fairly simple solution that I would have spent forever trying to figure out.
0
CodeCruiserCommented:
Glad to help :-)
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
Visual Basic.NET

From novice to tech pro — start learning today.