0

基本上我有一个没有边框的表格,我想保持这样。它处于固定位置。我正在尝试在表单中绘制表单大小的轮廓(因此它看起来像边框)我遇到了麻烦并且从未真正在表单中使用过“绘图”技术。

Pen pen = new Pen(Color.Black, 20);
Rectangle rect = new Rectangle(0, 0, this.Width, this.Height);
Graphics g = CreateGraphics();
g.DrawRectangle(pen, rect);
4

1 回答 1

3

这样做OnPaint

protected override void OnPaint(PaintEventArgs e) {
    base.OnPaint(e);
    Pen pen = new Pen(Color.Black, 20);
    Rectangle rect = new Rectangle(0, 0, this.Width, this.Height);
    e.Graphics.DrawRectangle(pen, rect);
}
于 2012-12-19T23:56:37.507 回答