locked
Display a progress bar within a column in the DataGridView RRS feed

  • Question

  • Hi ,
    I want to display a progress bar within a column inside a datagridview .
    Sample code below. I want Column 3 to show a progress bar with 70% used bar instead of just the boring text 70.
    Please help

    CLS
     Add-Type -AssemblyName System.Windows.Forms
        Add-Type -AssemblyName System.Drawing
    
        
            
        $Form = New-Object system.Windows.Forms.Form
        $Form.StartPosition = "CenterScreen"
        $Form.Topmost = $True
        $Form.size = New-Object System.Drawing.Size(400,400)
        
        $row = @( "A1", "B1" , "70" )
    
        $dataGridView = New-Object 'System.Windows.Forms.DataGridView'
        $dataGridView.Location = '5,15'
        $dataGridView.Size = '440,575'
         
        $dataGridView.Dock = 'Fill'
        $dataGridView.AutoSizeColumnsMode = 'DisplayedCells'
        $dataGridView.AllowUserToAddRows= $false
        $dataGridView.ReadOnly = $True
         
        $dataGridView.AllowUserToOrderColumns = $True
        $dataGridView.AllowUserToResizeColumns = $True
        $dataGridView.AllowUserToResizeRows = $True
        
        $dataGridView.ColumnCount = 3
        
        $dataGridView.ColumnHeadersVisible = $true
    
        $dataGridView.Rows.Add($row)
    
        $Form.Controls.Add($dataGridView)
        
        $Form.ShowDialog()


    Thursday, November 2, 2017 12:14 AM

All replies

  • This link does what I want to do , but its in C#. Can someone please show me an example in POWERSHELL.

    https://www.codeproject.com/Articles/117021/How-to-Create-ProgressBar-Column-in-DataGridView

    Thursday, November 2, 2017 12:18 AM
  • You would have to create a custom control in a compiled language or write code to do this in the "Paint" event of the control.  There is no way to directly embed a progress control in a DGV.


    \_(ツ)_/


    • Edited by jrv Thursday, November 2, 2017 12:19 AM
    Thursday, November 2, 2017 12:19 AM