PowerShell – DataGridView – Table Properties

Welcome Forums General PowerShell Q&A PowerShell – DataGridView – Table Properties

Viewing 1 reply thread
  • Author
    • #218340
      Topics: 2
      Replies: 0
      Points: 25
      Rank: Member

      I am looking to improve the layout and sorting options of my datagridview table. The code, shared below, is working and it is presenting the information correctly. However, my limited powershell skills does not help me on making some improvements such as adding sorting option for the first “date-time” column, add color to the rows based on the alert message (information (white), degradation, disruption (red)), and adding an option to shrink or expand the rows. Please, Please, if you have a suggestion on to improve the code and the goal is still achieved, please teach me with an example what to change.Thanks!

      $outputBox040 = Invoke-WebRequest -Uri ‘https://*.rss’ -OutFile C:\*.rss
      [xml]$Content = Get-Content C:\*.rss
      $Feed = $Content.rss.channel
      $url = foreach ($msg in $Feed.item){
      $commentsPlain = $msg.description.InnerText -replace ‘<br ?/?>’,[System.Environment]::NewLine -replace ‘<[^>]+>’
      ‘Date-Time’ = [datetime]$msg.pubDate
      ‘Title’ = “$($msg.title), ,
      #’Link’ = $msg.link.InnerText
      #’Comments’ = $commentsPlain
      ‘Category’ = $msg.category

      $list = New-Object System.collections.ArrayList
      $outputbox040 = New-Object System.Windows.Forms.DataGridView -Property @{
      Size=New-Object System.Drawing.Size(718,505)
      Location = New-Object System.Drawing.Size(0,1)
      ColumnHeadersVisible = $true
      AutoSizeColumnsMode = ‘DisplayedCellsExceptHeader’
      AutoSizeRowsMode = ‘AllCells’
      AllowUserToDeleteRows = ‘false’
      DefaultCellStyle= @{WrapMode =’True’}
      RowHeadersVisible = $false
      ReadOnly = ‘true’
      DataSource = $list

    • #218379
      Topics: 4
      Replies: 2231
      Points: 5,414
      Helping Hand
      Rank: Community MVP

      When you crosspost the same question at the same time to different forums you should at least post links to the other forums along with your question to avoid people willing to you help making their work twice or more.



Viewing 1 reply thread
  • You must be logged in to reply to this topic.