Looking for help with DataGrid

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 10 years and 11 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
jimbobukii
Posts: 52
Last visit: Mon Dec 04, 2017 9:59 am

Looking for help with DataGrid

Post by jimbobukii »

Could anyone point me in the right direction of when I should use DataGrid and how? I have a few lookups which I think could work but need to understand DataGrid
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Looking for help with DataGrid

Post by jvierra »

Here is a good resource. Scroll forward for datagrid
User avatar
jimbobukii
Posts: 52
Last visit: Mon Dec 04, 2017 9:59 am

Re: Looking for help with DataGrid

Post by jimbobukii »

jvierra wrote:Here is a good resource. Scroll forward for datagrid
I don't understand?
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Looking for help with DataGrid

Post by jvierra »

Sorry - the link I posted seems to have disappeared.

Try this: http://www.sapien.com/blog/topics/spotl ... -controls/
User avatar
jimbobukii
Posts: 52
Last visit: Mon Dec 04, 2017 9:59 am

Re: Looking for help with DataGrid

Post by jimbobukii »

jvierra wrote:Sorry - the link I posted seems to have disappeared.

Try this: http://www.sapien.com/blog/topics/spotl ... -controls/
I don't seem to see any information regarding GridView
I did check the SpotLights first or am I missing something?
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: Looking for help with DataGrid

Post by davidc »

I don't have an article on the DataGridView yet, but it’s on my to-do list.

I recommend referencing the MSDN for help on the control:

DataGridView:

http://msdn.microsoft.com/en-us/library ... dView.aspx

DataGrid:

http://msdn.microsoft.com/en-us/library ... dView.aspx

I also recommend searching the forums, for we have answered variously questions about the control.

David
David
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: Looking for help with DataGrid

Post by jvierra »

I have a PFF with a demo that I can upload later.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Looking for help with DataGrid

Post by jvierra »

Here is a simple demo that loists processes in a DataGrid:
PowerShell Code
Double-click the code block to select all.
$FormEvent_Load={
	#TODO: Initialize Form Controls here
	$arraylist=New-Object System.Collections.ArrayList
     $skuInfo=get-process
     $arraylist.AddRange($skuInfo)
     $datagrid1.DataSource=$arraylist
}
Most PowerShell objects can just be wrapped in an ArrayList and they will display.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Looking for help with DataGrid

Post by jvierra »

You can use the exact same technique with the DataGridView control.
PowerShell Code
Double-click the code block to select all.
$FormEvent_Load={
	#TODO: Initialize Form Controls here
	$arraylist=New-Object System.Collections.ArrayList
     $skuInfo=get-process
     $arraylist.AddRange($skuInfo) 
     $datagridview1.DataSource=$arraylist
}
User avatar
jimbobukii
Posts: 52
Last visit: Mon Dec 04, 2017 9:59 am

Re: Looking for help with DataGrid

Post by jimbobukii »

Thanks for the replies I am now making ground. I do however would like to know if this is possible

I am using the following to get my data:
PowerShell Code
Double-click the code block to select all.
$skuInfo= Get-command | Get-subcommand| select one, two, three, four, five, Status | sort -Property four -Descending
so all my columns are generated automaitaclly. I would like to know:
1. How do I get the datagrid to set colum width to the largest data (not a fixed width)
2. How do I get the datagrid to have an auto width rather than a specified one?

Thank you for your help
This topic is 10 years and 11 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