using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Data;
using System.Text;
using System.Windows.Forms;namespace WindowsControlLibrary1
{
public partial class UserControl1 : System.Windows.Forms.UserControl
{ private System.ComponentModel.Container components;
private Pen curvepen = new Pen(Color.Blue);
private Point pt1 = new Point(0, 0);
private Point pt2 = new Point(10, 30);
private Point pt3 = new Point(50, 20);
private Point pt4 = new Point(100, 40);
public UserControl1()
{
InitializeComponent();
}
public void InitializeComponent()
{
components = new System.ComponentModel.Container(); } public override void Dispose()
{ base.Dispose();
components.Dispose();
}
public Point PT1
{
get
{
return pt1;
}
set{
pt1 =value;
Invalidated();
}
} public Point PT2
{
get
{
return pt2;
}
set
{
pt2 = value;
Invalidated();
}
}
public Point PT3
{
get
{
return pt3;
}
set
{
pt3 = value;
Invalidated();
}
}
public Point PT4
{
get
{
return pt4;
}
set
{
pt4 = value;
Invalidated();
}
}
protected override void OnPaintBackground(PaintEventArgs e)
{
Rectangle r = new Rectangle(0,0,this.Size.Width,this.Size.Height);
LinearGradientBrush lb = new LinearGradientBrush(r,Color.Red,Color.Yellow,LinearGradientMode.BackwardDiagonal); e.Graphics.FillRectangle(lb,r);
} protected override void OnPaint(PaintEventArgs e)
{ base.OnPaint(e);
e.Graphics.DrawBezier(curvepen,pt1,pt2,pt3,pt4);
e.Graphics.DrawEllipse(curvepen,pt1.X-1,pt1.Y-1,3,3);
e.Graphics.DrawEllipse(curvepen, pt2.X - 1, pt2.Y - 1, 3, 3);
e.Graphics.DrawEllipse(curvepen, pt3.X - 1, pt3.Y - 1, 3, 3);
e.Graphics.DrawEllipse(curvepen, pt4.X - 1, pt4.Y - 1, 3, 3);
}
}
}
清高手解决并运行成功!谢谢
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Data;
using System.Text;
using System.Windows.Forms;namespace WindowsControlLibrary1
{
public partial class UserControl1 : System.Windows.Forms.UserControl
{ private System.ComponentModel.Container components;
private Pen curvepen = new Pen(Color.Blue);
private Point pt1 = new Point(0, 0);
private Point pt2 = new Point(10, 30);
private Point pt3 = new Point(50, 20);
private Point pt4 = new Point(100, 40);
public UserControl1()
{
InitializeComponent();
}
public void InitializeComponent()
{
components = new System.ComponentModel.Container(); } public override void Dispose()
{ base.Dispose();
components.Dispose();
}
public Point PT1
{
get
{
return pt1;
}
set{
pt1 =value;
Invalidated();
}
} public Point PT2
{
get
{
return pt2;
}
set
{
pt2 = value;
Invalidated();
}
}
public Point PT3
{
get
{
return pt3;
}
set
{
pt3 = value;
Invalidated();
}
}
public Point PT4
{
get
{
return pt4;
}
set
{
pt4 = value;
Invalidated();
}
}
protected override void OnPaintBackground(PaintEventArgs e)
{
Rectangle r = new Rectangle(0,0,this.Size.Width,this.Size.Height);
LinearGradientBrush lb = new LinearGradientBrush(r,Color.Red,Color.Yellow,LinearGradientMode.BackwardDiagonal); e.Graphics.FillRectangle(lb,r);
} protected override void OnPaint(PaintEventArgs e)
{ base.OnPaint(e);
e.Graphics.DrawBezier(curvepen,pt1,pt2,pt3,pt4);
e.Graphics.DrawEllipse(curvepen,pt1.X-1,pt1.Y-1,3,3);
e.Graphics.DrawEllipse(curvepen, pt2.X - 1, pt2.Y - 1, 3, 3);
e.Graphics.DrawEllipse(curvepen, pt3.X - 1, pt3.Y - 1, 3, 3);
e.Graphics.DrawEllipse(curvepen, pt4.X - 1, pt4.Y - 1, 3, 3);
}
}
}
清高手解决并运行成功!谢谢
解决方案 »
- 一段ATM登录代码 求说解……
- dt.Select("CODE = '" + mh.CODE + "'")[0]是空值如何判断
- 创建窗口句柄时出错
- 类似于sogou.com 的网页预览功能
- System.setproperty
- 100分,问高手一个很简单的问题!问题解决立即揭贴!
- 小问题,帮帮忙。~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- C++读取二进制文件转成C#读取二进制文件的问题!!!
- 关于动态链接库问题
- treelist 统计子节点
- winform中启动word,word关闭时如何得知用户是否选择保存
- 老问题!在一个窗体中刷新另一个窗体的方法!
然后输入这段代码
然后就可以在程序里调用这个控件了你自己添加个Invalidated()函数的定义试试~
还有dispose()函数你改改~