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


C# Control.Update方法代码示例

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


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

示例1: Show

 public static WIP Show(Control parent) {
     WIP o = new WIP();
     o.Location = Point.Empty;
     o.Size = parent.ClientSize;
     o.Parent = parent;
     o.Show();
     o.BringToFront();
     o.Update();
     parent.Update();
     return o;
 }
开发者ID:windrobin,项目名称:kumpro,代码行数:11,代码来源:WIP.cs

示例2: DisposableCursor

        /// <summary>
        /// Initializes an instance of the DisposableCursor class with the specified cursor displayed for the specified control.
        /// </summary>
        /// <param name="control">The control to display the cursor over.</param>
        /// <param name="newCursor">The cursor to display while the mouse pointer is over the control.</param>
        public DisposableCursor(Control control, Cursor newCursor)
        {
            if (control == null)
                throw new ArgumentNullException(nameof(control));
            if (newCursor == null)
                throw new ArgumentNullException(nameof(newCursor));

            this.previousCursor = control.Cursor;
            this.control = control;
            control.Cursor = newCursor;
            control.Update();
        }
开发者ID:dbremner,项目名称:lessmsi,代码行数:17,代码来源:DisposableCursor.cs

示例3: ValidateControl

        public static void ValidateControl(Control c, bool passedValidation)
        {
            if (!passedValidation)
            {

                c.BackColor = Color.Yellow;
            }
            else
            {
                c.BackColor = Color.White;
            }
            c.Update();
        }
开发者ID:siwiwit,项目名称:andromda,代码行数:13,代码来源:ValidationUtils.cs

示例4: SetTextBoxText

        string SetTextBoxText(Control textbox,
            string strText)
        {
            string strOldText = textbox.Text;

            textbox.Text = strText;
            textbox.Update();

            return strOldText;
        }
开发者ID:renyh1013,项目名称:dp2,代码行数:10,代码来源:Stop.cs

示例5: Safe_SetTextBoxText

        // 线程安全版本
        string Safe_SetTextBoxText(Control textbox,
            string strText)
        {
            if (textbox.Parent != null && textbox.Parent.InvokeRequired)
            {
                Delegate_SetTextBoxText d = new Delegate_SetTextBoxText(SetTextBoxText);
                return (string)textbox.Parent.Invoke(d, new object[] { textbox, strText });
            }
            else
            {
                string strOldText = textbox.Text;

                textbox.Text = strText;
                textbox.Update();


                return strOldText;
            }
        }
开发者ID:renyh1013,项目名称:dp2,代码行数:20,代码来源:Stop.cs

示例6: TestPublicMethods


//.........这里部分代码省略.........
			// - 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");
			c.SelectNextControl (new Control (), true, true, true, true);
			Assert.IsFalse (c.IsHandleCreated, "A35");
			c.SetBounds (0, 0, 100, 100);
			Assert.IsFalse (c.IsHandleCreated, "A36");
			c.Update ();
			Assert.IsFalse (c.IsHandleCreated, "A37");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:101,代码来源:ControlHandleTest.cs

示例7: TrackHandle

        protected bool TrackHandle(int nHandle,Control frm,Point point,Form frmClipTo)
        {
            Debug.Assert(nHandle >= 0);
            Debug.Assert(nHandle <= 8);   // handle 8 is inside the rect

            // don't handle if capture already set
            //if(frm.Capture) return false;

            Debug.Assert(!m_bFinalErase);

            // save original width & height in pixels
            int nWidth = m_rect.Width;
            int nHeight = m_rect.Height;

            // set capture to the window which received this message
            frm.Capture=true;
            Debug.Assert(frm.Capture);
            frm.Update();
            if (frmClipTo!=null)
                frmClipTo.Update();
            Rectangle rectSave = m_rect;

            // find out what x/y coords we are supposed to modify
            int px=0, py=0;
            int xDiff=0, yDiff=0;
            GetModifyPointers(nHandle,ref px,ref py,ref xDiff,ref yDiff,true);
            xDiff = point.X - xDiff;
            yDiff = point.Y - yDiff;

            // get DC for drawing
            Graphics gs;
            if (frmClipTo!=null)
            {
                // clip to arbitrary window by using adjusted Window DC
                gs=frmClipTo.CreateGraphics();
            }
            else
            {
                // otherwise, just use normal DC
                gs=frm.CreateGraphics();
            }

            Rectangle rectOld;
            bool bMoved = false;

            // get messages until capture lost or cancelled/accepted
            for (;;)
            {
                MSG msg=new MSG();
                if(GetMessage(ref msg, 0, 0, 0)!=1) break;
                if(!frm.Capture) break;

                switch (msg.message)
                {
                        // handle movement/accept messages
                    case WM_LBUTTONUP:
                    case WM_MOUSEMOVE:
                        rectOld = m_rect;
                        // handle resize cases (and part of move)
                        SetRectInt(px,LoWord(msg.lParam) - xDiff);
                        SetRectInt(py,HiWord(msg.lParam) - yDiff);
                        // handle move case
                        if (nHandle == (int)TrackerHit.hitMiddle)
                        {
                            m_rect.Width=nWidth;
                            m_rect.Height=nHeight;
                        }
                        // allow caller to adjust the rectangle if necessary
                        AdjustRect(nHandle,ref m_rect);

                        // only redraw and callback if the rect actually changed!
                        m_bFinalErase = (msg.message == WM_LBUTTONUP);
                        if (m_bFinalErase)
                            goto ExitLoop;

                        if (!rectOld.Equals(m_rect) || m_bFinalErase)
                        {
                            if (bMoved)
                            {
                                m_bErase = true;
                                DrawTrackerRect(rectOld, frmClipTo, gs, frm);
                            }
                            OnChangedRect(rectOld);
                            if (msg.message != WM_LBUTTONUP)
                                bMoved = true;
                        }
                        if (m_bFinalErase)
                            goto ExitLoop;

                        if (!rectOld.Equals(m_rect))
                        {
                            m_bErase = false;
                            DrawTrackerRect(m_rect, frmClipTo, gs, frm);
                        }
                        break;

                        // handle cancel messages
                    case WM_KEYDOWN:
                        if (msg.wParam != 0x1B)//VK_ESCAPE
                            break;
//.........这里部分代码省略.........
开发者ID:Myvar,项目名称:MyvarNode,代码行数:101,代码来源:RectTracker.cs

示例8: AddControl


//.........这里部分代码省略.........
         size2 = (Size) defaultValues["Offset"];
     }
     IDesignerHost host = (IDesignerHost) this.GetService(typeof(IDesignerHost));
     if ((((host != null) && (newChild != null)) && (!this.Control.Contains(newChild) && (host.GetDesigner(newChild) is ControlDesigner))) && (!(newChild is Form) || !((Form) newChild).TopLevel))
     {
         Rectangle dragRect = new Rectangle();
         if (flag)
         {
             empty = this.Control.PointToClient(empty);
             dragRect.X = empty.X;
             dragRect.Y = empty.Y;
         }
         else
         {
             ISelectionService service = (ISelectionService) this.GetService(typeof(ISelectionService));
             object primarySelection = service.PrimarySelection;
             Control controlForComponent = null;
             if (primarySelection != null)
             {
                 controlForComponent = ((IOleDragClient) this).GetControlForComponent(primarySelection);
             }
             if ((controlForComponent != null) && (controlForComponent.Site == null))
             {
                 controlForComponent = null;
             }
             if ((primarySelection == base.Component) || (controlForComponent == null))
             {
                 dragRect.X = this.DefaultControlLocation.X;
                 dragRect.Y = this.DefaultControlLocation.Y;
             }
             else
             {
                 dragRect.X = controlForComponent.Location.X + this.GridSize.Width;
                 dragRect.Y = controlForComponent.Location.Y + this.GridSize.Height;
             }
         }
         if (flag2)
         {
             dragRect.Width = size.Width;
             dragRect.Height = size.Height;
         }
         else
         {
             dragRect.Size = this.GetDefaultSize(newChild);
         }
         if (!flag2 && !flag)
         {
             Rectangle adjustedSnapLocation = this.GetAdjustedSnapLocation(Rectangle.Empty, dragRect);
             dragRect = this.GetControlStackLocation(adjustedSnapLocation);
         }
         else
         {
             dragRect = this.GetAdjustedSnapLocation(Rectangle.Empty, dragRect);
         }
         dragRect.X += size2.Width;
         dragRect.Y += size2.Height;
         if ((defaultValues != null) && defaultValues.Contains("ToolboxSnapDragDropEventArgs"))
         {
             ToolboxSnapDragDropEventArgs e = defaultValues["ToolboxSnapDragDropEventArgs"] as ToolboxSnapDragDropEventArgs;
             Rectangle rectangle3 = DesignerUtils.GetBoundsFromToolboxSnapDragDropInfo(e, dragRect, this.Control.IsMirrored);
             Control rootComponent = host.RootComponent as Control;
             if ((rootComponent != null) && rectangle3.IntersectsWith(rootComponent.ClientRectangle))
             {
                 dragRect = rectangle3;
             }
         }
         PropertyDescriptor member = TypeDescriptor.GetProperties(this.Control)["Controls"];
         if (this.componentChangeSvc != null)
         {
             this.componentChangeSvc.OnComponentChanging(this.Control, member);
         }
         this.AddChildControl(newChild);
         PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(newChild);
         if (properties != null)
         {
             PropertyDescriptor descriptor2 = properties["Size"];
             if (descriptor2 != null)
             {
                 descriptor2.SetValue(newChild, new Size(dragRect.Width, dragRect.Height));
             }
             Point point2 = new Point(dragRect.X, dragRect.Y);
             ScrollableControl parent = newChild.Parent as ScrollableControl;
             if (parent != null)
             {
                 Point autoScrollPosition = parent.AutoScrollPosition;
                 point2.Offset(-autoScrollPosition.X, -autoScrollPosition.Y);
             }
             descriptor2 = properties["Location"];
             if (descriptor2 != null)
             {
                 descriptor2.SetValue(newChild, point2);
             }
         }
         if (this.componentChangeSvc != null)
         {
             this.componentChangeSvc.OnComponentChanged(this.Control, member, this.Control.Controls, this.Control.Controls);
         }
         newChild.Update();
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:101,代码来源:ParentControlDesigner.cs

示例9: CaptureControl

 /// <summary>
 /// Capture a specific control in the client area of a form.
 /// </summary>
 /// <param name="window">This is a control which should be captured.</param>
 /// <returns>The image which has been captured.</returns>
 public virtual Bitmap CaptureControl(Control window)
 {
     Rectangle rc = window.RectangleToScreen(window.DisplayRectangle);
     window.Update();
     return capture(window, rc);
 }
开发者ID:ChrisPelatari,项目名称:XunitForms,代码行数:11,代码来源:ScreenCapture.cs

示例10: ForceRefresh

 private void ForceRefresh(Control c)
 {
     c.Invalidate();
     c.Update();
     c.Refresh();
 }
开发者ID:Basewq,项目名称:gitextensions,代码行数:6,代码来源:GitFlowForm.cs

示例11: SetPictureBoxColor

 private void SetPictureBoxColor(Control pbox, Color col)
 {
     if (pbox.InvokeRequired)
     {
         SetPictureBoxColorCallback d = new SetPictureBoxColorCallback(SetPictureBoxColor);
         this.Invoke(d, new object[] { pbox, col });
     }
     else
     {
         pbox.BackColor = col;
         //proximityStateLbl.Text = col.ToString();
         pbox.Update();
     }
 }
开发者ID:aliotta,项目名称:Samples,代码行数:14,代码来源:Form1.cs

示例12: AddUseControls

        /// <summary>
        ///在指定的控件中添加用户控件。
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="userControl"></param>
        public virtual void AddUseControls(Control parent, IWindow userControl)
        {
            if (parent != null && userControl != null)
            {
                UserControl uc = userControl as UserControl;
                if (uc != null)
                {
                    uc.AutoSize = true;
                    if (uc.Dock == DockStyle.Fill)
                        parent.Controls.Clear();
                    parent.Controls.Add(uc);
                    parent.Update();

                    userControl.MessageEvent += this.OnMessageEvent;
                    userControl.ToolTipEvent += this.OnToolTipEvent;
                    userControl.SetErrorEvent += this.OnSetErrorEvent;
                    userControl.ClearErrorEvent += this.OnClearErrorEvent;
                }
            }
        }
开发者ID:jeasonyoung,项目名称:csharp_sfit,代码行数:25,代码来源:BaseUserControl.cs


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