在Paint 事件中画矩形
在button_clicked 中调用Invalidate();

解决方案 »

  1.   

    感谢您使用微软产品。您可以通过Form对象的CreateGraphics()方法来获得其Graphics对象。然后,通过Graphics对象的DrawRectangle方法来绘制矩形。
    下面提供一段示例程序,供您参考:using System.Drawing;
    using System.Drawing.Drawing2D;
    ……
    private void button1_Click(object sender, System.EventArgs e)
    {
    Graphics g = this.CreateGraphics();
    // Create pen.
    Pen bluePen = new Pen(Color.Blue, 3);
    // Create location and size of rectangle.
    float x = 10.0F;
    float y = 10.0F;
    float width = 200.0F;
    float height = 200.0F;
    // Draw rectangle to screen.
    g.DrawRectangle(bluePen, x, y, width, height);
    g.Dispose();
    }关于CreateGraphics方法的更详细信息,请参考微软MSDN:
    ms-help://MS.VSCC/MS.MSDNVS/cpref/html/frlrfSystemWindowsFormsControlClassCreateGraphicsTopic.htm— 微软全球技术中心 VB支持中心本贴子以“现状”提供且没有任何担保,同时也没有授予任何权利。具体事项可参见使用条款(http://support.microsoft.com/directory/worldwide/zh-cn/community/terms_chs.asp)。
    为了为您创建更好的讨论环境,请参加我们的用户满意度调查(http://support.microsoft.com/directory/worldwide/zh-cn/community/survey.asp?key=(S,49854782))。
      

  2.   

    在button- licked中调用paint事件函数,参数用null,null代替,我没试过
    不知道行不行