Share this page

Set Method (IToggleButton)
Sets the value of this toggle button.

C# Syntax

    void Set(
       CheckedState state
    )

Parameters

state
  The value to be assigned to this toggle button. Possible values: HP.LFT.SDK.CheckedState.

Example

    // The following code example changes the state of the toggle button.

    [Test]
    public void TestWpfToggleButton()
    {
        // Identify the application and assign it to an IWindow object.
        var appMainWindow = Desktop.Describe<IWindow>(new WindowDescription
        {
            ObjectName = @"MainWindow",
            FullType = @"window",
            WindowTitleRegExp = @"MainWindow"
        });

        // Identify the WPF toggle button.
        var buttonWithToggleButtonSupport = appMainWindow.Describe<IButton>(new ButtonDescription
        {
            Text = @"Toggle Button",
            ObjectName = @"Button4"
        });
        IToggleButton toggleButton = buttonWithToggleButtonSupport.ToggleButton;

        // Sets the toggle button's state to checked.
        toggleButton.Set(CheckedState.Checked);

        // Changes the toggle button state.
        if (toggleButton.IsChecked)
        {
            toggleButton.Set(CheckedState.Unchecked);
        }
        else
        {
            toggleButton.Set(CheckedState.Checked);
        }
    }

Tips to improve your search results... UFT Developer .NET SDK Reference Version 15.0-15.0.2 UFT Developer SDK Reference All View Local Help Center View Online Help Center back Go back in browser history forward Go forward in browser history Remove search highlights next topic Go to next topic previous topic Go to previous topic Print the current topic Version: