Showing posts with label Winforms. Show all posts
Showing posts with label Winforms. Show all posts

2016/07/28

PowerShell/WinForms - Row Header

If you are creating Windows Forms (WinForms) using PowerShell with tools such as PowerShell Studio from Sapien, you might have some scenario where you want to use Row Header instead of Column Header in a DataGridView control.

Those can be controlled using the properties RowHeaderVisible and ColumnHeaderVisible.




Assuming you already have a form with a Datagridview in it, you will need to do the following:
  • Create a Column
  • Create a Row with the Header value (and optionally a value for the first column)
  • Add the Row to the DataGridView
  • Set RowHeaderVisible to $true
  • Set ColumnHeaderVisiable to $false (Optional)
(The example can be download on my github)


Creating a Column

# Create Column object
$NewColumn = New-Object -TypeName System.Windows.Forms.DataGridViewTextBoxColumn
$NewColumn.Name = "Column1"
$NewColumn.HeaderText = "Column1"

# Add the Column to the Datagridview
$DataGridView.Columns.Add($NewColumn)

2015/02/15

Introducing WinFormPS: PowerShell module to interact with WinForms controls


I started to work on a PowerShell module called WinFormPS.
This module contains a few functions that let you interact with Windows Form controls such as DataGridView, ListBox or Button controls for example.

To build those forms I mostly use PowerShell Studio from Sapien but this can also work with any simple Form created from scratch.

The motivation to create User Interfaces has always been to ease the work of  departments and teams with some of their heavy tasks, or simply to speed up some very repetitive processes. I definitely don't have a developer background, so please bear with me and feel free to critique or push update to the module on GitHub :-)


WinForms
Windows Forms (WinForms) is the name given to a graphical (GUI) class library included as a part of Microsoft .NET Framework, providing a platform to write rich client applications for desktop, laptop, and tablet. While it is seen as a replacement for the earlier and more complex C++ based Microsoft Foundation Class Library, it does not offer a comparable paradigm and only act as a platform for the user interface tier in a multi-tier solution. -Wikipedia