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 correctly designed. There is no need to create a new row object with a DataTable as it has a method that generates a row when needed.
$r = $dataGridView.DataSource.NewRow()
or
$dataGridView.DataSource.Rows.Add(<array 0f values>)
Datagridview datasource
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.
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.
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
}
Re: Datagridview datasource
Hi,
maybe it's difficult to understand what i mean but i created a little part of my project. If i click on the edit button then i get the values of the selected row in the datagridview. No i want to Change the permission role and write them back to the datagridview / datatable as source. Later i want to change something else.
maybe it's difficult to understand what i mean but i created a little part of my project. If i click on the edit button then i get the values of the selected row in the datagridview. No i want to Change the permission role and write them back to the datagridview / datatable as source. Later i want to change something else.
- Attachments
-
- DatagridviewExampleDatatable.psf
- (31.32 KiB) Downloaded 133 times
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.
- Attachments
-
- Demo-DGVDataTable.psf
- (37.52 KiB) Downloaded 122 times
Re: Datagridview datasource
Hi,
this file is internal linked to a New-PersonForm.ps1. After them it will create a new row but i want to update an existing row.
this file is internal linked to a New-PersonForm.ps1. After them it will create a new row but i want to update an existing row.
Re: Datagridview datasource
Sorry I forgot to upload the form. Here it is.
- Attachments
-
- New-PersonForm.ps1
- (5.89 KiB) Downloaded 120 times
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.
The code also needs validation and error handling to be a robust editor. It would also work with less code if I used full data binding.
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.
The code also needs validation and error handling to be a robust editor. It would also work with less code if I used full data binding.
- Attachments
-
- Demo-DGVDataTable3.psf
- (37.69 KiB) Downloaded 127 times
Re: Datagridview datasource
This version adds the ability to cancel both an edit and an add.
- Attachments
-
- Demo-DGVDataTable3.psf
- (37.69 KiB) Downloaded 101 times
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.
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.
- Attachments
-
- Demo-DGVDataTable3.psf
- (38.01 KiB) Downloaded 153 times