datagridview datatable update method

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 6 years and 10 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
dan.potter
Posts: 709
Last visit: Wed Nov 14, 2018 11:39 am

datagridview datatable update method

Post by dan.potter »

Why doesn't the update method work for programmatic changes to the datagridview?

This is what I was trying to do.
  1. $datagridview2.SelectedRows | %{
  2.             $_.Cells[6].Value = $ostemplate.SelectedItem
  3.         }
  4.        
  5.         $invadapter.Update($datagridview2.DataSource)
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: datagridview datatable update method

Post by jvierra »

No idea what you are asking about. An Data Adapter only works when connected to a database and is provided with a table or dataset that is correctly provisioned with update statements.
User avatar
dan.potter
Posts: 709
Last visit: Wed Nov 14, 2018 11:39 am

Re: datagridview datatable update method

Post by dan.potter »

That'll all done. Datasource is sql. When you change the value cell manually and use the update method it writes the changes back to sql. If I change a cell value $row.cells[1].value = 'something' and call the update method it doesn't.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: datagridview datatable update method

Post by jvierra »

You have to update the underlying data as the cell change is not posted to the data except in the GUI. YOU can try to refresh the row after the update as that can flush the change to the data source.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: datagridview datatable update method

Post by jvierra »

You can also try EndEdit on the row view.
This topic is 6 years and 10 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked