Search found 12892 matches

by jvierra
Sun Nov 11, 2018 6:53 pm
Forum: PowerShell GUIs
Topic: Datagridview datasource
Replies: 19
Views: 242

Re: Datagridview datasource

This one adds the "delete" ability using the "Delete" key. It prompts for confirmation.

Note that these changes all take only a few lines of code. Deleting is three lines.

Point is that once you understand how forms are intended to work and are programmed nothing should take more than a few lines.
by jvierra
Sun Nov 11, 2018 6:33 pm
Forum: PowerShell GUIs
Topic: Datagridview datasource
Replies: 19
Views: 242

Re: Datagridview datasource

This version adds the ability to cancel both an edit and an add.
by jvierra
Sun Nov 11, 2018 6:28 pm
Forum: PowerShell GUIs
Topic: Datagridview datasource
Replies: 19
Views: 242

Re: Datagridview datasource

In the above example note that you double click a row to edit.
by jvierra
Sun Nov 11, 2018 12:30 pm
Forum: PowerShell GUIs
Topic: Datagridview datasource
Replies: 19
Views: 242

Re: Datagridview datasource

I quickly modified the example to also allow editing. Double click any row to open in edit form. I also embedded the subform for now. It should be a project with two PSF files but I wanted to make it simple demo when I first built it about two years ago. Maybe I will clean it up as a project later. ...
by jvierra
Sun Nov 11, 2018 12:09 pm
Forum: PowerShell GUIs
Topic: Datagridview datasource
Replies: 19
Views: 242

Re: Datagridview datasource

Sorry I forgot to upload the form. Here it is.
by jvierra
Sun Nov 11, 2018 11:45 am
Forum: PowerShell GUIs
Topic: Datagridview datasource
Replies: 19
Views: 242

Re: Datagridview datasource

I dug around and found this old example of how to add a row to a DGV that is populated from a set of textboxes.
by jvierra
Sun Nov 11, 2018 9:52 am
Forum: PowerShell GUIs
Topic: Datagridview datasource
Replies: 19
Views: 242

Re: Datagridview datasource

The following is one way to get the selected rows data table row to update it.

Code: Select all

$datagridview1_CellDoubleClick=[System.Windows.Forms.DataGridViewCellEventHandler]{
#Event Argument: $_ = [System.Windows.Forms.DataGridViewCellEventArgs]
	$datagridview1.Rows[$_.RowIndex].DataBoundItem
}
by jvierra
Sun Nov 11, 2018 9:47 am
Forum: PowerShell GUIs
Topic: Datagridview datasource
Replies: 19
Views: 242

Re: Datagridview datasource

No. I posted some examples of ho to do databinding and how to add a row or edit a row using the underlying table. Until you understand how that works your posts will be hard for me to understand because you are just posting guesses without any understanding. I also have no idea if your code is corre...
by jvierra
Sun Nov 11, 2018 9:03 am
Forum: PowerShell GUIs
Topic: Datagridview datasource
Replies: 19
Views: 242

Re: Datagridview datasource

Select and where do not update anything. A DataGridView is not a DataTable. To update a DataTable row bound to a grid you need the row from the grid and its underlying "DataBoundItem" which is the table row, Here are some examples of ways to use data binding with controls. https://tech-comments.blog...
by jvierra
Sun Nov 11, 2018 8:02 am
Forum: PowerShell GUIs
Topic: Datagridview datasource
Replies: 19
Views: 242

Re: Datagridview datasource

Hi jvierra, A button reads out the selected row from the datagridview and put the value to textboxes. Now i want to update the selected row with the edited values from the textboxes. Is that possible or should i delete the full row and add the values from the textboxes to a new row in my datatable?...