- function Load-UserInfo (){
- $importData = Import-Csv "\\computer\log\Info-20160418 080018.csv" | Select-Object Username, ComputerName, City, "I/P Address" -Unique
- Load-DataGridView -DataGridView $userDatagridview1 -Item $importData
- }
- $softwareTreeview1_NodeMouseClick = [System.Windows.Forms.TreeNodeMouseClickEventHandler]{
- if (!(Test-Path -path $_.Node.Name -PathType container))
- {
- return
- }
- $_.Node.Nodes.Clear()
- foreach ($dir in ([System.io.DirectoryInfo]$_.Node.Name).GetFiles())
- {
- $_.Node.Nodes.Add($dir.FullName, $dir.Name)
- }
- }
- $userDatagridview1_CellContentClick=[System.Windows.Forms.DataGridViewCellEventHandler]{
- #Event Argument: $_ = [System.Windows.Forms.DataGridViewCellEventArgs]
- #TODO: Place custom script here
- $usernameRow = $userDatagridview1.Rows[$_.RowIndex].Cells[1].Value
- $computernameRow = $userDatagridview1.Rows[$_.RowIndex].Cells[2].Value
- $cityRow = $userDatagridview1.Rows[$_.RowIndex].Cells[3].Value
- $IPaddrow = $userDatagridview1.Rows[$_.RowIndex].Cells[4].Value
- $usernameRow, $computernameRow, $cityRow, $IPaddrow | ForEach-Object{
- Load-DataGridView -DataGridView $installDatagridview2 -Item $_
- }
moving data from one datagridview to another datagridview
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.
moving data from one datagridview to another datagridview
I am importing a csv and into a gridview with a extra column called selection that has check boxes. I want to be able to click the check box in one grid view and the data be added to another grid view. I trying to understand what I am missing. When I check the bo it gives me numbers in the other gridview. the csv columns are selection, username, computer name, city, IP Address. Added my code below.
Re: moving data from one datagridview to another datagridview
At my point I had learned in the last 2 month, Datagridview(DGV) and DataTable(DT) is important.
1. Create DT1.
2. Import the CSV in DT1 and bind it to DGV1.
3. Create DT2 and bind it to DGV2
3. If a CellClick is happen, you get the row counter from the source and copy the row from one DT to the second.
The DGV2 will refresh itself.
The advantage is that you can work in the DT(in memory) and don't have to write directly in the DGV.
regards
mono
1. Create DT1.
2. Import the CSV in DT1 and bind it to DGV1.
3. Create DT2 and bind it to DGV2
3. If a CellClick is happen, you get the row counter from the source and copy the row from one DT to the second.
The DGV2 will refresh itself.
The advantage is that you can work in the DT(in memory) and don't have to write directly in the DGV.
regards
mono
Re: moving data from one datagridview to another datagridview
You can also just use the "SelectedRows" collection "CopyTo" method to copy the rows directly.
https://msdn.microsoft.com/en-us/librar ... .110).aspx
$dgv1.SelectedRows.CopyTo($dgv2.Rows,0)
https://msdn.microsoft.com/en-us/librar ... .110).aspx
$dgv1.SelectedRows.CopyTo($dgv2.Rows,0)
Re: moving data from one datagridview to another datagridview
Hi jvierra,
Your link doesn't work also I was trying to use what you gave me and I am getting the error below
Your link doesn't work also I was trying to use what you gave me and I am getting the error below
ERROR: Multiple ambiguous overloads found for "CopyTo" and the argument count: "2".
Re: moving data from one datagridview to another datagridview
Sorry Not sure what broke the link:
https://msdn.microsoft.com/en-us/librar ... s.90).aspx
This link should work. This forum has a tendency to trash links. I had to be very careful to create it very carefully to get it to work.
https://msdn.microsoft.com/en-us/librar ... s.90).aspx
This link should work. This forum has a tendency to trash links. I had to be very careful to create it very carefully to get it to work.
Re: moving data from one datagridview to another datagridview
Cool is see the link now. But it seems like it doesn't like the overload for CopyTo. I made my line like below.
- $userDatagridview1_CellContentClick=[System.Windows.Forms.DataGridViewCellEventHandler]{
- #Event Argument: $_ = [System.Windows.Forms.DataGridViewCellEventArgs]
- #TODO: Place custom script here
- $userDatagridview1.SelectedRows.CopyTo($installDatagridview2.Rows, 0)
- }
Multiple ambiguous overloads found for "CopyTo" and the argument count: "2".
Re: moving data from one datagridview to another datagridview
Unfortunately the "CopyTo" does not appear to work if we are not using a dataset. The recommended method is to manually copy each row and cell.
Re: moving data from one datagridview to another datagridview
Here is a working example of how to copy rows when there is no dataset.
- Attachments
-
- Demo-DGVCopyTo.psf
- (23.17 KiB) Downloaded 255 times
Re: moving data from one datagridview to another datagridview
jvierra,
Thanks for this I see what you did. Got it to populate without the button.
Thanks for this I see what you did. Got it to populate without the button.