private void button1_Click(object sender, EventArgs e) { TestCheckBox frm = new TestCheckBox(); //将子窗体设置非最高层,非顶级控件 frm.TopLevel = false; frm.WindowState = FormWindowState.Maximized; //去掉窗体边框 frm.FormBorderStyle = FormBorderStyle.None; //指定子窗体显示的容器 frm.Parent = this.panel1; frm.Show(); }
public void CheckBox_RaiseAutomationEvent_Invoke_Success() { using var checkBox = new TestCheckBox(); Assert.False(checkBox.IsHandleCreated); var accessibleObject = (SubCheckBoxAccessibleObject)checkBox.AccessibilityObject; Assert.Equal(0, accessibleObject.RaiseAutomationEventCallsCount); Assert.Equal(0, accessibleObject.RaiseAutomationPropertyChangedEventCallsCount); checkBox.Checked = true; Assert.Equal(1, accessibleObject.RaiseAutomationEventCallsCount); Assert.Equal(1, accessibleObject.RaiseAutomationPropertyChangedEventCallsCount); Assert.False(checkBox.IsHandleCreated); }
public void CheckBox_RaiseAutomationEvent_Invoke_Success() { using var checkBox = new TestCheckBox(); Assert.False(checkBox.IsHandleCreated); var accessibleObject = (SubCheckBoxAccessibleObject)checkBox.AccessibilityObject; Assert.Equal(0, accessibleObject.RaiseAutomationEventCallsCount); Assert.Equal(0, accessibleObject.RaiseAutomationPropertyChangedEventCallsCount); checkBox.Checked = true; Assert.Equal(1, accessibleObject.RaiseAutomationEventCallsCount); Assert.Equal(1, accessibleObject.RaiseAutomationPropertyChangedEventCallsCount); // TODO: ControlAccessibleObject shouldn't force handle creation, tracked in https://github.com/dotnet/winforms/issues/3062 Assert.True(checkBox.IsHandleCreated); }