I searched for this, but didn't find anything in the first 15 pages of search results.
I have a DataGridView that I have setup so when you click, it selects the entire Row.
How do I get the value to a string of the FIRST cell in the row that is selected?
DataGridView: Value of first Cell in Selected Row
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.
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.
Re: DataGridView: Value of first Cell in Selected Row
PowerShell Code
Double-click the code block to select all.$datagridview1_CellContentClick=[System.Windows.Forms.DataGridViewCellEventHandler]{ #Event Argument: $_ = [System.Windows.Forms.DataGridViewCellEventArgs] $cell=$datagridview1.Rows[$_.RowIndex].Cells[$_.ColumnIndex].Value [void][System.Windows.Forms.MessageBox]::Show($cell,"test") }
Re: DataGridView: Value of first Cell in Selected Row
Here is the same thing in the row changed event:
PowerShell Code
Double-click the code block to select all.$datagridview1_SelectionChanged={ $r=$datagridview1.SelectedRows[0].Cells[0].Value [void][System.Windows.Forms.MessageBox]::Show($r,"test") }
Re: DataGridView: Value of first Cell in Selected Row
Unfortunately that only gives me the cell clicked on in the row. I actually need the first cell in the row, regardless of the cell clicked in the row. Does that make sense?
EDIT: Actually, the second option you listed did the trick. Thanks!
EDIT: Actually, the second option you listed did the trick. Thanks!