Thanks you very much for all your help.
Here is what i have now in WPF:
<ComboBox x:Name="mdb" HorizontalAlignment="Left" VerticalAlignment="Top" Width="275" Grid.Column="1" DisplayMemberPath="Expr1000" SelectedValuePath="SAPstruktur" ItemsSource="{Binding PsList[GetData]}" SelectedIndex="0" />
<ComboBox x:Name="SecondCombobox" HorizontalAlignment="Left" VerticalAlignment="Top" Width="275" DisplayMemberPath="Expr1000" SelectedValuePath="SAPstruktur" SelectedIndex="0" Margin="0,43,0,0" Grid.Column="1" />
<ComboBox x:Name="thirdcombobox" HorizontalAlignment="Left" VerticalAlignment="Top" Width="275" Grid.Column="1" DisplayMemberPath="Expr1000" SelectedValuePath="SAPstruktur" SelectedIndex="0" Margin="0,91,0,0"/>
And here is content of the ps.1
function InitializeWindow
{
$dsWindow.Width = 600
$dsWindow.Height = 400
$dsDiag.ShowLog()
$dsDiag.Clear()
$firstcombobox = $dsWindow.FindName("mdb")
$secondcombobox = $dsWindow.FindName("SecondCombobox")
$thirdcombobox= $dsWindow.FindName("thirdcombobox")
$firstcombobox.add_SelectionChanged(
{
param($sender,$args)
FeedCombobox($sender.SelectedValue, $secondCombobox)
})
$secondcombobox.add_SelectionChanged(
{
param($sender,$args)
FeedCombobox($sender.SelectedValue, $thirdcombobox)
})
$thirdcombobox.add_SelectionChanged(
{
param($sender,$args)
$textbox= $dsWindow.FindName("text_combobox")
$textbox.Text = $send.SelectedValue
})function FeedCombobox($selectedValue, $cmbbx)
{
$objOleDbConnection1= New-Object "System.Data.OleDb.OleDbConnection"
$objOleDbCommand = New-Object "System.Data.OleDb.OleDbCommand"
$objOleDbAdapter = New-Object "System.Data.OleDb.OleDbDataAdapter"
$objDataTable = New-Object "System.Data.DataTable"
$objOleDbConnection1.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Script\test_1.mdb;"
$objOleDbConnection1.Open()
$objOleDbCommand.Connection = $objOleDbConnection1
$objOleDbCommand.CommandText = "SELECT SAPstruktur + ' ' + '-' + ' ' + Tekst, SAPstruktur FROM SAPstruktur where SAPstruktur like 'NK' ORDER BY ID ASC"
$itemsForCombobox = "SELECT SAPstruktur + ' ' + '-' + ' ' + Tekst, SAPstruktur FROM SAPstruktur where SAPstruktur = '$selectedValue' ORDER BY ID ASC"
$cmbbx.ItemsSource = $itemsForCombobox
#set the Adapter object
$objOleDbAdapter.SelectCommand = $objOleDbCommand
#fill the objDataTable object with the results
$objOleDbAdapter.Fill($objDataTable)
#$mdb.ItemsSource = @($objDataTable)
#$mdb.DisplayMemberPath = "Expr1000"
#$mdb.SelectedValuePath = "SAPstruktur"
#To display the "raw" contents, just enter
return $objDataTable.DefaultView
$objOleDbConnection1.Close()
}Content of combobox "mdb"
function GetData
{
$objOleDbConnection1= New-Object "System.Data.OleDb.OleDbConnection"
$Tier2ClassificationCategory = New-Object System.Windows.Forms.ComboBox
$objOleDbCommand = New-Object "System.Data.OleDb.OleDbCommand"
$objOleDbAdapter = New-Object "System.Data.OleDb.OleDbDataAdapter"
$objDataTable = New-Object "System.Data.DataTable"
$objOleDbConnection1.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Script\test_1.mdb;"
$objOleDbConnection1.Open()
$objOleDbCommand.Connection = $objOleDbConnection1
$objOleDbCommand.CommandText = "SELECT SORT + ' ' + '-' + ' ' + Tekst, SAPstruktur FROM SAPstruktur where SAPstruktur like 'A__' ORDER BY ID ASC"
#set the Adapter object
$objOleDbAdapter.SelectCommand = $objOleDbCommand
$Tier2ClassificationCategory.SelectedIndex = -1
#fill the objDataTable object with the results
$objOleDbAdapter.Fill($objDataTable)
#To display the "raw" contents, just enter
return $objDataTable.DefaultView
$objOleDbConnection1.Close()
}Before each of comboboxes had its own "GetData" function. Now logically only the first one will have it.
I'm not sure if i do all correct, because i do not get any results in Secondcombobox.
Do i need to do any changes to binding between comboboxes and ps1? What should be binded to ItemsSource i WPF?
Thanks a lot!