Advertisement

Visual Studio WPF Form, pass Combobox selection to Process StartInfo.Arguments?

Started by April 01, 2020 08:39 AM
1 comment, last by SpammyCollector5005 4 years, 7 months ago

I have a combo box that selects what language the game will run in.

<ComboBox x:Name="Lang" HorizontalAlignment="Left" Margin="600,418,0,0" VerticalAlignment="Top" Width="73" SelectionChanged="ComboBox_SelectionChanged">
            <ComboBoxItem Content="English" Name="en" IsSelected="True"></ComboBoxItem>
            <ComboBoxItem Content="French" Name="fr"></ComboBoxItem>
            <ComboBoxItem Content="German" Name="de"></ComboBoxItem>
        </ComboBox>

I also have a button to launch our game's EXE

private void Button_Play(object sender, RoutedEventArgs e)
        {
            Process Game = new Process();

            Game.StartInfo.FileName = "Game.exe"; // Needs to be full path
            Game.StartInfo.Arguments = ""; // If you have any arguments

            bool result = Game.Start();
        }

How can I put the Name value from the combo box into the “Game.StartInfo.Arguments”?

Presume I need to take the combo box value and put it into a string? Then call that string in the “”?

Thanks

Jack

The code to get the string is like Lang.selectedvalue. So Game.StartInfo.Arguments = Lang.selectedvalue;

This topic is closed to new replies.

Advertisement