System.Windows.Automation.ValuePattern.SetValue C# (CSharp) Méthode

SetValue() public méthode

public SetValue ( string value ) : void
value string
Résultat void
        public void SetValue(string value)
        {
            try
            {
                this._pattern.SetValue(value);
            }
            catch (System.Runtime.InteropServices.COMException e)
            {
                Exception newEx; if (Utility.ConvertException(e, out newEx)) { throw newEx; } else { throw; }
            }
        }

Usage Example

Exemple #1
0
        // -------------------------------------------------------------------
        // Call ValuePattern.SetValue("123456789") on control whose limit is set to 1 character
        // -------------------------------------------------------------------
        private void TS_SetValueOversize(ValuePattern valuePattern, CheckType checkType)
        {
            bool isReadOnly = valuePattern.Current.IsReadOnly;
            bool isPassword = m_le.Current.IsPassword;
            string value = "123456789";
            IntPtr _hwnd = Helpers.CastNativeWindowHandleToIntPtr(m_le);
            NativeMethods.HWND hwnd = NativeMethods.HWND.Cast(_hwnd);
            IntPtr wParam = new IntPtr(1);
            IntPtr result;

            int    lastWin32Error    = Marshal.GetLastWin32Error();
            int    resultInt;

            IntPtr resultSendMessage = UnsafeNativeMethods.SendMessageTimeout(hwnd, NativeMethods.EM_LIMITTEXT, wParam, IntPtr.Zero, 1, 10000, out result);
            if (resultSendMessage == IntPtr.Zero)
            {
                throw new InvalidOperationException("SendMessageTimeout() timed out");
            }
            resultInt = unchecked((int)(long)result);

            try
            {
                valuePattern.SetValue(value);
            }
            catch (InvalidOperationException)
            {
                Comment("As expected, unable to set value of control limited to 1 character with a string \"123456789\"");
            }
            catch (UnauthorizedAccessException actualException)
            {
                if (isPassword == true)
                {
                    Comment("As expected, unable to set value of password control (UnauthorizedAccessException)");
                    m_TestStep++;
                    return;
                }
                else
                    TestException(null, actualException, "TS_SetValue", checkType);
            }
            catch (Exception actualException)
            {
                if (Library.IsCriticalException(actualException))
                    throw;

                TestException(null, actualException, "TS_SetValue", checkType);
            }

            Comment("Successfully called ValuePattern.SetValue(\"A\"), must be control that is not numeric-only");
            m_TestStep++;
        }
All Usage Examples Of System.Windows.Automation.ValuePattern::SetValue