资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

vb.net做图形选择 vb绘制图形程序

用VB.NET绘制GDI图形

下面的例子通过重载Form 窗体的OnPaint()方法绘制GDI图形Protected Overrides Sub onpaint(ByVal e As System Windows Forms PaintEventArgs)注释 /////////////绘制任意直线Dim g As Graphics = e GraphicsDim mypen As Pen = New Pen(Color Red )g DrawLine(mypen )注释 /////////////绘制矩形(任意直线构成的封闭图形)Dim point As PointF = New PointF( F F)Dim point As PointF = New PointF( F F)Dim point As PointF = New PointF( F F)Dim point As PointF = New PointF( F F)Dim curvepoints As PointF() = {point point point point }g DrawPolygon(New Pen(Color Blue ) curvepoints)注释 ////////////文本表示Dim FFamily As FontFamily = New FontFamily( Arial )Dim font As Font = New Font(FFamily FontStyle Bold FontStyle Italic GraphicsUnit Pixel)Dim text As String = I love you! Dim solidbrush As SolidBrush = New SolidBrush(Color Red)Dim pr As PointF = New PointF( )e Graphics DrawString(text font solidbrush pr)注释 ////////////平面绘制Dim rec As RectangleF = New RectangleF( )g DrawPie(mypen rec )注释 ///////////封闭图形 应该是个圆g DrawClosedCurve(mypen curvepoints Drawing Drawing D FillMode Alternate)注释 ///////////大家自己试试看吧g DrawArc(mypen )g DrawCurve(mypen curvepoints)g DrawBezier(mypen )g DrawBeziers(mypen curvepoints)注释 //////////这可是一个圆Dim rec As RectangleF = New RectangleF( )g DrawEllipse(mypen rec )注释 //////////这是一个椭圆Dim rec As RectangleF = New RectangleF( )g DrawEllipse(mypen rec )End Sub 这些是我自己试验出来的 当然了 还有好多 我只是开了一个头 大家要是发现什么好东东 别忘了通知一下 ) lishixinzhi/Article/program/net/201311/11800

为北海街道等地区用户提供了全套网页设计制作服务,及北海街道网站建设行业解决方案。主营业务为成都做网站、成都网站设计、北海街道网站设计,以传统方式定制建设网站,并提供域名空间备案等一条龙服务,秉承以专业、用心的态度为用户提供真诚的服务。我们深信只要达到每一位用户的要求,就会得到认可,从而选择与我们长期合作。这样,我们也可以走得更远!

vb.net读取txt的数据作图问题

一、分析:

1,这一类随时间而变化的曲线图,通常把横轴作为时间,把纵轴作为相应的值,在这里就是密度值。

2,点的集合就是线;一组时间、密度值,对应一个点,把点连接起来就构成了线。

二、在VB.NET中作图,需要知道并解决几个问题:

1,与VB6一样,VB.NET中默认的坐标系统,左上角为坐标原点,X轴的正向为从左向右,Y轴的正向是从上向下。

为了使得它与数学中的坐标系统相一致,可以使用VB.NET中Graphics类的两个方法;

1、TranslateTransform----平移变换

格式:Graphics.TranslateTransform(dx,dy)

其中:dx 和 dy分别是Single数据类型

2、ScaleTransform----缩放变换

格式:Graphics.ScaleTransform(sx,sy)

其中:sx 和 sy分别是Single数据类型;

例如:为了符合数学中的一般格式,可以使用下述代码:

Graphics.ScaleTransform(1, -1)

这样就把Y轴的正方向给翻过来了。

三、VB.NET中绘制图形

1,绘制圆或椭圆

'绘制图形的三步曲

'1,获得一个Graphics对象

Dim MyGraphics As Graphics

MyGraphics = Me.CreateGraphics

'2,定义一个Pen对象,用于绘制图形(轮廓线)

Dim MyPen As New Pen(Color.Black)

'3,定义一个Brush对象,用于填充图形(如果需要填充的话)

Dim MyBrush As New SolidBrush(Color.Orange)

'绘制一个实心圆,该圆在:直线x=200,y=200,x=200+100,y=200+100所划的矩形区域内

MyGraphics.FillEllipse(Brush, 200, 200, 100, 100)

'绘制一个空心圆,该圆在:直线x=200,y=200,x=200+100,y=200+100所划的矩形区域内

MyGraphics.DrawEllipse(Pen, 200, 200, 100, 100)

注意:最后两个数值如果不等,就是绘制椭圆

当圆足够小,就是点了。

2,绘制直线

'1,获得一个Graphics对象

Dim MyGraphics As Graphics

MyGraphics = Me.CreateGraphics

'2,定义一个Pen对象,用于绘制图形(轮廓线)

Dim MyPen As New Pen(Color.Black)

MyGraphics.DrawLine(MyPen, 200, 200, 100, 100)

'或者直接用

Me.CreateGraphics.DrawLine(New Pen(Color.Black), 50, 50, 200, 200)

vb.net中,如何点击按钮调出选择文件窗口选中图片并在picturebox中显示出来?

button , OpenFileDialog , PictureBox , textbox 控件,我把图片显示在 picturebox 中,而路

径存放在 textbox 中,不知道这样行不行。

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim filename As String

OpenFileDialog1.Filter = "jpg files (*.jpg)|*.jpg"

OpenFileDialog1.FilterIndex = 1

If OpenFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then

filename = OpenFileDialog1.FileName

Else

End

End If

If Not (PictureBox1.Image Is Nothing) Then

PictureBox1.Image.Dispose()

PictureBox1.Image = Nothing

End If

'PictureBox1.Image = System.Drawing.Image.FromFile(filename)

去掉注释后就显示图片

TextBox1.Text = filename

End Sub

picturebox中只记录文件存放的路径,我找了一个 ImageLocation 函数

PictureBox1.ImageLocation = filename 不过还是会显示图片


分享文章:vb.net做图形选择 vb绘制图形程序
链接分享:http://cdkjz.cn/article/hhjppo.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

业务热线:400-028-6601 / 大客户专线   成都:13518219792   座机:028-86922220