GUI - Display data - table format - color? how?

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
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.
User avatar
lontru
Posts: 23
Joined: Fri Aug 18, 2017 4:36 am

GUI - Display data - table format - color? how?

Post by lontru » Sun Nov 04, 2018 2:56 pm

Hi

How do i view data like this gui below in powershell studio? table with formatted headers?

Image

User avatar
jvierra
Posts: 12874
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: GUI - Display data - table format - color? how?

Post by jvierra » Sun Nov 04, 2018 3:02 pm

Only two choices. Either use a RichTextBox control with custom output, use a DataGridView with custom painting and coloring or use ListView with custom building.

User avatar
jvierra
Posts: 12874
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: GUI - Display data - table format - color? how?

Post by jvierra » Sun Nov 04, 2018 3:03 pm

There are really only three choices. Either use a RichTextBox control with custom output, use a DataGridView with custom painting and coloring or use ListView with custom building.

User avatar
Alexander Riedel
Posts: 6684
Joined: Tue May 29, 2007 4:43 pm

Re: GUI - Display data - table format - color? how?

Post by Alexander Riedel » Sun Nov 04, 2018 6:34 pm

You could generate HTML and use a browser view. But the control in the screenshot (.NET app) is most likely a Listview with groups.
A C# example is here: http://csharphelper.com/blog/2014/08/use-listview-groups-in-c/
Should be relatively easy to transfer.
Alexander Riedel
SAPIEN Technologies, Inc.

User avatar
jvierra
Posts: 12874
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: GUI - Display data - table format - color? how?

Post by jvierra » Sun Nov 04, 2018 6:56 pm

Ahh. yes. The web browser would also be quite easy. I missed that one. To get colored headers and other styles use a CSS style sheet.

The bigger issue is that the example shows a list and not a table. This may be a misuse of nomenclature and a list is what is required. If a table is really what you want then it would have one very wide row which would not be very useful visually. It is a table if you really do want to show a table of properties and values. My guess is that the control being used is a DataGridView. If that is true then you can just set the headers colors and make rows alternate colors for readability.

"ExportTo-Csv" can build a colorized list fairly easily.

User avatar
jvierra
Posts: 12874
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: GUI - Display data - table format - color? how?

Post by jvierra » Sun Nov 04, 2018 7:30 pm

After another look at the image I agree with Alex. It is likely a grouped ListView.

User avatar
lontru
Posts: 23
Joined: Fri Aug 18, 2017 4:36 am

Re: GUI - Display data - table format - color? how?

Post by lontru » Mon Nov 05, 2018 12:33 am

Thanks for all the feedback im looking into your suggestions

User avatar
lontru
Posts: 23
Joined: Fri Aug 18, 2017 4:36 am

Re: GUI - Display data - table format - color? how?

Post by lontru » Mon Nov 05, 2018 2:21 pm

Code: Select all

$button_search_Click={
	Add-ListViewItem -ListView $listview_systeminfo -Items "Computer Name" -Group "General" -ImageIndex 0 -SubItems "General"
	Add-ListViewItem -ListView $listview_systeminfo -Items "User" -Group "General" -ImageIndex 0 -SubItems "General"
	Add-ListViewItem -ListView $listview_systeminfo -Items "Last Restart" -Group "General" -ImageIndex 0 -SubItems "General"
}

Image

not getting the expected result want to format is like the exsample above.

Property;Value?

How do i provide the value with the property?

User avatar
jvierra
Posts: 12874
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: GUI - Display data - table format - color? how?

Post by jvierra » Mon Nov 05, 2018 2:30 pm

You have to add items that have subitems with those names.

User avatar
lontru
Posts: 23
Joined: Fri Aug 18, 2017 4:36 am

Re: GUI - Display data - table format - color? how?

Post by lontru » Thu Nov 08, 2018 3:43 pm

Image

Got a little further since I posted.

Is there a way to get the data in the listview
Want to make a button to export the data to a file

Post Reply