Solved - Select value from combox box by value 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 1 year and 1 month 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

Solved - Select value from combox box by value how?

Post by lontru »

How do i select from a combo box.

I want to DoubleClick on the datagridview1 and get the selected value with

$logfile = $datagridview1.Rows[$($datagridview1.CurrentCell.RowIndex)].Cells[0].Value

how do i select the same "file" in the combobox? by code when double click action?
PowerShell_Studio_vDnGOx1yoC.gif
PowerShell_Studio_vDnGOx1yoC.gif (288.04 KiB) Viewed 504 times
Attachments
gridview_combo_test.psf
(22 KiB) Downloaded 35 times
Last edited by lontru on Tue Jan 31, 2023 5:14 am, edited 1 time in total.
User avatar
lontru
Posts: 103
Last visit: Thu Mar 07, 2024 2:00 pm

Re: Select value from combox box by value how?

Post by lontru »

$combobox1.SelectedIndex = $combobox1.Items.IndexOf("$logfile")

did the trick

Code: Select all

$datagridview1_DoubleClick={
	$logfile = $datagridview1.Rows[$($datagridview1.CurrentCell.RowIndex)].Cells[0].Value
	$textbox1.Text = $logfile
	$combobox1.SelectedIndex = $combobox1.Items.IndexOf("$logfile")
}
This topic is 1 year and 1 month 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