Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

save changes to a datagridview - colour the rows 1

Status
Not open for further replies.

steve1rm

Programmer
Aug 26, 2006
255
GB
Hello,

[VS 2005]

I am using typed datasets. I have 2 datagridView and when I click one GridA it will add a row to GridB. This works fine and the data is saved to the database.

However, the customer wants to add the rows to GridB and save periodically.

I am wondering is there a way to show the rows that have not been saved, and when the user clicks the save button it will change them to a different colour.

So it will commit some rows everytime the user clicks save. The user can add some more rows and they will be displayed in blue. Once the user clicks save all the rows that have just been added will be saved to the database and then change colour to green.

Can anyone point me in the right direction or give me some code example, will be most grateful.

Many thanks,

Steve
 
What you're asking is pretty broad. What is your dataSource's type? Hopefully, a DataSet/DataTable coz then you can take advantage of its state caching features.

If you use a DataSet/DataTable, you can read on
AcceptChanges()
RejectChanges()
GetChanges()

(If you use a TableAdapter (w/ CRUD properties set) to save the changes, it will commit to the database the rows that were actually modified/deleted, then, when successful, sets each row's state to default/unmodified. see DataRow.RowState property on MSDN)

Just to give you a start, hopefully [wink]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top