当前位置: 首页>>代码示例>>C#>>正文


C# Control.Contains方法代码示例

本文整理汇总了C#中System.Windows.Forms.Control.Contains方法的典型用法代码示例。如果您正苦于以下问题:C# Control.Contains方法的具体用法?C# Control.Contains怎么用?C# Control.Contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Forms.Control的用法示例。


在下文中一共展示了Control.Contains方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: displayFormOnPanel

 public static void displayFormOnPanel(Control.ControlCollection control, Form newForm)
 {
     bool isExist = control.Contains(newForm);
     if (isExist == false)
     {
         newForm.TopLevel = false;    //设置为非顶级窗体
         newForm.FormBorderStyle = FormBorderStyle.None;       //设置窗体为非边框样式
         newForm.Dock = System.Windows.Forms.DockStyle.Fill;   //设置样式是否填充整个PANEL
         control.Add(newForm);      //添加窗体
         newForm.Show();
     }
     newForm.BringToFront();
 }
开发者ID:qq5013,项目名称:KryptonAccessController,代码行数:13,代码来源:WidgetThread.cs

示例2: CallControlContains

		public static object CallControlContains(Control c, object[] obj)
		{
			return c.Contains((Control)(obj[0]));
		}
开发者ID:HosokawaKenchi,项目名称:powersdr-if-stage,代码行数:4,代码来源:invoke.cs

示例3: AfterControlRemoved

        /// <devdoc>
        ///     Cleans up form state after a control has been removed.
        ///     Package scope for Control
        /// </devdoc>
        /// <internalonly/>
        internal virtual void AfterControlRemoved(Control control, Control oldParent) {
            ContainerControl cc;
            Debug.Assert(control != null);
            Debug.WriteLineIf(Control.FocusTracing.TraceVerbose, "ContainerControl::AfterControlRemoved(" + control.Name + ") - " + this.Name);
            if (control == activeControl || control.Contains(activeControl)) {
                bool selected;
                // SECREVIEW : Note that a function overriding "protected virtual void Control::Select(bool directed, bool forward)"
                //             called by SelectNextControl will be able to set the focus to any control.
                //             This is also enabled by the ModifyFocus.Assert inside Control::SelectNextIfFocused.
                IntSecurity.ModifyFocus.Assert ();
                try
                {
                    selected = SelectNextControl(control, true, true, true, true);
                }
                finally
                {
                    CodeAccessPermission.RevertAssert ();
                }
                if (selected && this.activeControl != control)
                {
                    FocusActiveControlInternal();
                }
                else
                {
                    SetActiveControlInternal(null);
                }
            }
            else if (activeControl == null && ParentInternal != null)
            {
                // The last control of an active container was removed. Focus needs to be given to the next
                // control in the Form.
                cc = ParentInternal.GetContainerControlInternal() as ContainerControl;
                if (cc != null && cc.ActiveControl == this)
                {
                    Form f = FindFormInternal();
                    if (f != null)
                    {
                        // SECREVIEW : Same comment as above.
                        IntSecurity.ModifyFocus.Assert ();
                        try
                        {
                            f.SelectNextControl(this, true, true, true, true);
                        }
                        finally
                        {
                            CodeAccessPermission.RevertAssert();
                        }
                    }
                }
            }

            // VSWhidbey#262686: Two controls in UserControls that don't take focus via UI can have bad behavior if ...
            // VSWhidbey#537131: 
            // When a control is removed from a container, not only do we need to clear the unvalidatedControl of that 
            // container potentially, but the unvalidatedControl of all its container parents, up the chain, needs to
            // now point to the old parent of the disappearing control.
            cc = this;
            while (cc != null) {
                Control parent = cc.ParentInternal;
                if (parent == null) {
                    break;
                }
                else {
                    cc = parent.GetContainerControlInternal() as ContainerControl;
                }
                if (cc != null &&
                    cc.unvalidatedControl != null &&
                    (cc.unvalidatedControl == control || control.Contains(cc.unvalidatedControl)))
                {
                    cc.unvalidatedControl = oldParent;
                }
            }

            if (control == unvalidatedControl || control.Contains(unvalidatedControl)) {
                unvalidatedControl = null;
            }
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:82,代码来源:ContainerControl.cs

示例4: TestPublicMethods

		public void TestPublicMethods ()
		{
			// Public Methods that force Handle creation:
			// - CreateControl ()
			// - CreateGraphics ()
			// - GetChildAtPoint ()
			// - Invoke, BeginInvoke throws InvalidOperationException if Handle has not been created
			// - PointToClient ()
			// - PointToScreen ()
			// - RectangleToClient ()
			// - RectangleToScreen ()
			Control c = new Control ();
			
			c.BringToFront ();
			Assert.IsFalse (c.IsHandleCreated, "A1");
			c.Contains (new Control ());
			Assert.IsFalse (c.IsHandleCreated, "A2");
			c.CreateControl ();
			Assert.IsTrue (c.IsHandleCreated, "A3");
			c = new Control ();
			Graphics g = c.CreateGraphics ();
			g.Dispose ();
			Assert.IsTrue (c.IsHandleCreated, "A4");
			c = new Control ();
			c.Dispose ();
			Assert.IsFalse (c.IsHandleCreated, "A5");
			c = new Control ();
			//DragDropEffects d = c.DoDragDrop ("yo", DragDropEffects.None);
			//Assert.IsFalse (c.IsHandleCreated, "A6");
			//Assert.AreEqual (DragDropEffects.None, d, "A6b");
			//Bitmap b = new Bitmap (100, 100);
			//c.DrawToBitmap (b, new Rectangle (0, 0, 100, 100));
			//Assert.IsFalse (c.IsHandleCreated, "A7");
			//b.Dispose ();
			c.FindForm ();
			Assert.IsFalse (c.IsHandleCreated, "A8");
			c.Focus ();
			Assert.IsFalse (c.IsHandleCreated, "A9");

			c.GetChildAtPoint (new Point (10, 10));
			Assert.IsTrue (c.IsHandleCreated, "A10");
			c.GetContainerControl ();
			c = new Control ();
			Assert.IsFalse (c.IsHandleCreated, "A11");
			c.GetNextControl (new Control (), true);
			Assert.IsFalse (c.IsHandleCreated, "A12");
#if NET_2_0
			c.GetPreferredSize (Size.Empty);
			Assert.IsFalse (c.IsHandleCreated, "A13");
#endif
			c.Hide ();
			Assert.IsFalse (c.IsHandleCreated, "A14");
			c.Invalidate ();
			Assert.IsFalse (c.IsHandleCreated, "A15");
			//c.Invoke (new InvokeDelegate (InvokeMethod));
			//Assert.IsFalse (c.IsHandleCreated, "A16");
			c.PerformLayout ();
			Assert.IsFalse (c.IsHandleCreated, "A17");
			c.PointToClient (new Point (100, 100));
			Assert.IsTrue (c.IsHandleCreated, "A18");
			c = new Control ();
			c.PointToScreen (new Point (100, 100));
			Assert.IsTrue (c.IsHandleCreated, "A19");
			c = new Control ();
			//c.PreProcessControlMessage   ???
			//c.PreProcessMessage          ???
			c.RectangleToClient (new Rectangle (0, 0, 100, 100));
			Assert.IsTrue (c.IsHandleCreated, "A20");
			c = new Control ();
			c.RectangleToScreen (new Rectangle (0, 0, 100, 100));
			Assert.IsTrue (c.IsHandleCreated, "A21");
			c = new Control ();
			c.Refresh ();
			Assert.IsFalse (c.IsHandleCreated, "A22");
			c.ResetBackColor ();
			Assert.IsFalse (c.IsHandleCreated, "A23");
			c.ResetBindings ();
			Assert.IsFalse (c.IsHandleCreated, "A24");
			c.ResetCursor ();
			Assert.IsFalse (c.IsHandleCreated, "A25");
			c.ResetFont ();
			Assert.IsFalse (c.IsHandleCreated, "A26");
			c.ResetForeColor ();
			Assert.IsFalse (c.IsHandleCreated, "A27");
			c.ResetImeMode ();
			Assert.IsFalse (c.IsHandleCreated, "A28");
			c.ResetRightToLeft ();
			Assert.IsFalse (c.IsHandleCreated, "A29");
			c.ResetText ();
			Assert.IsFalse (c.IsHandleCreated, "A30");
			c.SuspendLayout ();
			Assert.IsFalse (c.IsHandleCreated, "A31");
			c.ResumeLayout ();
			Assert.IsFalse (c.IsHandleCreated, "A32");
#if NET_2_0
			c.Scale (new SizeF (1.5f, 1.5f));
			Assert.IsFalse (c.IsHandleCreated, "A33");
#endif
			c.Select ();
			Assert.IsFalse (c.IsHandleCreated, "A34");
//.........这里部分代码省略.........
开发者ID:nlhepler,项目名称:mono,代码行数:101,代码来源:ControlHandleTest.cs

示例5: ChildControlRemoved

		internal void ChildControlRemoved (Control control)
		{
			ContainerControl top_container = FindForm ();
			if (top_container == null)
				top_container = this;

			// Remove controls -as well as any sub control- that was in the pending validation chain
			ArrayList pending_validation_chain = top_container.pending_validation_chain;
			if (pending_validation_chain != null) {
				RemoveChildrenFromValidation (pending_validation_chain, control);

				if (pending_validation_chain.Count == 0)
					top_container.pending_validation_chain = null;
			}

			if (control == active_control || control.Contains (active_control)) {
				SelectNextControl (this, true, true, true, true);
				if (control == active_control || control.Contains (active_control)) {
					active_control = null;
				}
			}
		}
开发者ID:carrie901,项目名称:mono,代码行数:22,代码来源:ContainerControl.cs

示例6: CanParent

 public virtual bool CanParent(Control control)
 {
     return !control.Contains(this.Control);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:4,代码来源:ParentControlDesigner.cs

示例7: ContainsTest

		public void ContainsTest ()
		{
			Control t = new Control ();
			Control s = new Control ();

			t.Controls.Add (s);

			Assert.AreEqual (true, t.Contains (s), "Con1");
			Assert.AreEqual (false, s.Contains (t), "Con2");
			Assert.AreEqual (false, s.Contains (null), "Con3");
			Assert.AreEqual (false, t.Contains (new Control ()), "Con4");
		}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:12,代码来源:ControlTest.cs

示例8: RelationTest

		public void RelationTest() {
			Control c1;
			Control c2;

			c1 = new Control();
			c2 = new Control();

			Assert.AreEqual(true , c1.Visible , "Rel1");
			Assert.AreEqual(false, c1.Contains(c2) , "Rel2");
			Assert.AreEqual("System.Windows.Forms.Control", c1.ToString() , "Rel3");

			c1.Controls.Add(c2);
			Assert.AreEqual(true , c2.Visible , "Rel4");
			Assert.AreEqual(true, c1.Contains(c2) , "Rel5");

			c1.Anchor = AnchorStyles.Top;
			c1.SuspendLayout ();
			c1.Anchor = AnchorStyles.Left ;
			c1.ResumeLayout ();
			Assert.AreEqual(AnchorStyles.Left , c1.Anchor, "Rel6");

			c1.SetBounds(10, 20, 30, 40) ;
			Assert.AreEqual(new Rectangle(10, 20, 30, 40), c1.Bounds, "Rel7");

			Assert.AreEqual(c1, c2.Parent, "Rel8");
		}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:26,代码来源:ControlTest.cs

示例9: AddtoPanel

        static void AddtoPanel(Control pControlToAdd, Control pContainerControl)
        {

            if (!pContainerControl.Contains(pControlToAdd))
            {
                pContainerControl.Controls.Add(pControlToAdd);
                pControlToAdd.Dock = DockStyle.Fill;
                //pContainerControl.Controls.Clear();

            }
            pControlToAdd.Dock = DockStyle.Fill;
            pControlToAdd.BringToFront();
        }
开发者ID:Pelsoft,项目名称:fwk_10.3,代码行数:13,代码来源:ControlsFactory.cs

示例10: CanParent

		// If the control is not already parented return true
		//
		public virtual bool CanParent (Control control)
		{
			if (control != null)
				return !control.Contains (this.Control);

			return false;
		}
开发者ID:Profit0004,项目名称:mono,代码行数:9,代码来源:ParentControlDesigner.cs

示例11: AfterControlRemoved

	// Brubbel
	internal virtual void AfterControlRemoved(Control control)
	{
		// Select next control, if control was active and removed.
		if (control == activeControl || control.Contains(activeControl))
		{
			if( base.SelectNextControl( control, true, true, true, true ) ) {
				this.SetFocus( activeControl );
			}
			else {
				this.SetActiveControl( null );
			}
		}
		else if( (this.activeControl == null) && (this.Parent != null) ) {
			ContainerControl container = Parent.GetContainerControl() as ContainerControl;
			if( null != container && container.ActiveControl == this ) {
				Form form = base.FindForm();
				if( null != form ) {
					form.SelectNextControl( this, true, true, true, true );
				}
				
			}
		}
		else {
		}
		
		// Make sure the unvalidated control and active control are cleaned up.
		if (control == unvalidatedControl || control.Contains(unvalidatedControl))
		{
			unvalidatedControl = null;
		}
	}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:32,代码来源:ContainerControl.cs

示例12: AfterControlRemoved

 internal virtual void AfterControlRemoved(Control control, Control oldParent)
 {
     ContainerControl containerControlInternal;
     if ((control == this.activeControl) || control.Contains(this.activeControl))
     {
         bool flag;
         System.Windows.Forms.IntSecurity.ModifyFocus.Assert();
         try
         {
             flag = base.SelectNextControl(control, true, true, true, true);
         }
         finally
         {
             CodeAccessPermission.RevertAssert();
         }
         if (flag)
         {
             this.FocusActiveControlInternal();
         }
         else
         {
             this.SetActiveControlInternal(null);
         }
     }
     else if ((this.activeControl == null) && (this.ParentInternal != null))
     {
         containerControlInternal = this.ParentInternal.GetContainerControlInternal() as ContainerControl;
         if ((containerControlInternal != null) && (containerControlInternal.ActiveControl == this))
         {
             Form form = base.FindFormInternal();
             if (form != null)
             {
                 System.Windows.Forms.IntSecurity.ModifyFocus.Assert();
                 try
                 {
                     form.SelectNextControl(this, true, true, true, true);
                 }
                 finally
                 {
                     CodeAccessPermission.RevertAssert();
                 }
             }
         }
     }
     containerControlInternal = this;
     while (containerControlInternal != null)
     {
         Control parentInternal = containerControlInternal.ParentInternal;
         if (parentInternal == null)
         {
             break;
         }
         containerControlInternal = parentInternal.GetContainerControlInternal() as ContainerControl;
         if (((containerControlInternal != null) && (containerControlInternal.unvalidatedControl != null)) && ((containerControlInternal.unvalidatedControl == control) || control.Contains(containerControlInternal.unvalidatedControl)))
         {
             containerControlInternal.unvalidatedControl = oldParent;
         }
     }
     if ((control == this.unvalidatedControl) || control.Contains(this.unvalidatedControl))
     {
         this.unvalidatedControl = null;
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:63,代码来源:ContainerControl.cs


注:本文中的System.Windows.Forms.Control.Contains方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。