关于画图位置的问题

qingqing08 2008-07-23 04:44:53
请问下我要在一个form下的tabcontrol中画图
请问下那初始点怎么取呢?

private void button6_Click(object sender, EventArgs e)
{
Graphics graphics = this.CreateGraphics();
Pen myPen = new Pen(Color.Black, 1);
int beginX =tabControl1.Location.X +50;
int beginY = tabControl1.Location.Y + 65;
//int height = 35;
//int width = 50;
Point pointX1 = new Point(beginX, beginY);
Point pointY1 = new Point(beginX + 210, beginY);
Point pointX2 = new Point(beginX, beginY - 45);
Point pointY2 = new Point(beginX, beginY + 45);
graphics.DrawLine(myPen, pointX1, pointY1);
graphics.DrawLine(myPen, pointX2, pointY2);

}

按上面的代码就是把图画在form上,被tabcontrol挡住看不见
...全文
115 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
北京的雾霾天 2008-07-23
  • 打赏
  • 举报
回复
至少应该使用:Graphics graphics = this.tabControl.CreateGraphics();
但TabControl有一个TabControl.DrawMode = TabDrawMode.OwnerDrawFixed;可以在DrawItem事件里绘制。

110,533

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧