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.
This topic is 5 years and 4 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
lontru
Posts: 103
Last visit: Thu Mar 07, 2024 2:00 pm

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

Post by lontru »

Hi

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

Image
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

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

Post by jvierra »

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.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

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

Post by jvierra »

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: 8479
Last visit: Thu Mar 28, 2024 9:29 am
Answers: 19
Been upvoted: 37 times

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

Post by Alexander Riedel »

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.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

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

Post by jvierra »

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.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

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

Post by jvierra »

After another look at the image I agree with Alex. It is likely a grouped ListView.
User avatar
lontru
Posts: 103
Last visit: Thu Mar 07, 2024 2:00 pm

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

Post by lontru »

Thanks for all the feedback im looking into your suggestions
User avatar
lontru
Posts: 103
Last visit: Thu Mar 07, 2024 2:00 pm

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

Post by lontru »

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?
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

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

Post by jvierra »

You have to add items that have subitems with those names.
User avatar
lontru
Posts: 103
Last visit: Thu Mar 07, 2024 2:00 pm

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

Post by lontru »

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
This topic is 5 years and 4 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked