Having datagridview not select a cell by default

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 7 years and 7 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
swindmiller
Posts: 64
Last visit: Tue Aug 22, 2023 11:59 am

Having datagridview not select a cell by default

Post by swindmiller »

Product, version and build: 2016 v5.2.127
32 or 64 bit version of product: 64
Operating system: Win10
32 or 64 bit OS: 64
PowerShell Version: 5

Upon loading a datagridview it selects the first cell. Is there a way to have it not select anything by default forcing a person to select a value? I have a submit button that uses the data in the cell selected but I don't want people to forget to click the right cell. Sometimes the first cell is not the correct one that they would need.

Does that make sense?

Thanks,
Scott
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: Having datagridview not select a cell by default

Post by davidc »

[TOPIC MOVED TO THE POWERSHELL GUIS FORUM BY MODERATOR]
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: Having datagridview not select a cell by default

Post by jvierra »

This will force no cell to be selected.

$datagridview1.CurrentCell = $null
User avatar
swindmiller
Posts: 64
Last visit: Tue Aug 22, 2023 11:59 am

Re: Having datagridview not select a cell by default

Post by swindmiller »

Wow...sorry, I don't know why I didn't think of this.


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

Re: Having datagridview not select a cell by default

Post by jvierra »

I had to think about that one for a while. Forgot about CurrentCEll.
This topic is 7 years and 7 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