Is it possible to do this in powershell ?
i found only this link in C++
https://stackoverflow.com/questions/958 ... tagridview
DataGridView add header cell number
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 add header cell number
I want to upload a datagridview, modify a gridview, and then export it to csv format.
All 3 processes work perfectly, creating a gridview and then assigning with this command that you see below, the datasource $dt which is my datatable.
The problem then is that when I do this, the numbers inside rows headers are no longer seen.
If i comment this line the headers numbers are displayed, otherwise no.
If, however, comment that line in the export phase I mistaken obviously why to export the data from a gridview must be associated with a dataTable
The second problem is that I do not know how many lines I will have to fill in the DataTable, so the numbering needs to be updated every time I insert a new line in the DataTable.
All 3 processes work perfectly, creating a gridview and then assigning with this command that you see below, the datasource $dt which is my datatable.
The problem then is that when I do this, the numbers inside rows headers are no longer seen.
- $dataGridView.Rows | %{ $_.HeaderCell.Value = ($_.Index +1).ToString() }
- #$dataGridView.DataSource = $dt
If, however, comment that line in the export phase I mistaken obviously why to export the data from a gridview must be associated with a dataTable
The second problem is that I do not know how many lines I will have to fill in the DataTable, so the numbering needs to be updated every time I insert a new line in the DataTable.
Re: DataGridView add header cell number
To make the refresh I should associate it with a button, I wonder if it is possible to enter the line number automatically.
For example, if the DataTable is empty, the first line header must already have the value 1, when i go to the second line the value must be 2 and so on.
For example, if the DataTable is empty, the first line header must already have the value 1, when i go to the second line the value must be 2 and so on.
Last edited by ramses147 on Fri May 26, 2017 4:17 pm, edited 1 time in total.
Re: DataGridView add header cell number
Something like this ?
- $aa = $dataGridView.Rows | %{ $_.HeaderCell.Value = ($_.Index +1).ToString() }
- $DataGridView.add_RowPostPaint($aa)
- $dataGridView.DataSource = $dt
- $form.Controls.Add($dataGridView)
Re: DataGridView add header cell number
Sorry. I see that post is missing here. I posted on TechNet.
Here it is again:
Here it is again:
- $datagridview1_RowPostPaint=[System.Windows.Forms.DataGridViewRowPostPaintEventHandler]{
- $datagridview1.Rows[$_.RowIndex].HeaderCell.Value = $_.RowIndex.ToString()
- }
Re: DataGridView add header cell number
I insert it after DataTable associtation, but give me error "Unable to find rowPostPaint" property in this object..
- $dataGridView.DataSource = $dt
- $datagridview.RowPostPaint=[System.Windows.Forms.DataGridViewRowPostPaintEventHandler]{
- $dataGridView.Rows[$_.RowIndex].HeaderCell.Value = $_.RowIndex.ToString()
- }