网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

vbnet画矩形 vb画矩形程序代码

vb.net画填充的方形矩形

Dim canvas As New ShapeContainer

让客户满意是我们工作的目标,不断超越客户的期望值来自于我们对这个行业的热爱。我们立志把好的技术通过有效、简单的方式提供给客户,将通过不懈努力成为客户在信息化领域值得信任、有价值的长期合作伙伴,公司提供的服务项目有:域名与空间、网页空间、营销软件、网站建设、永德网站维护、网站推广。

' To draw anoval, substitute

' OvalShapefor RectangleShape.

DimtheShape As NewRectangleShape

' Set theform as the parent of the ShapeContainer.

canvas.Parent = Me

' Set theShapeContainer as the parent of the Shape.

theShape.Parent = canvas

' Set thesize of the shape.

theShape.Size = New System.Drawing.Size(200,300)

' Set thelocation of the shape.

theShape.Location = New System.Drawing.Point(100,100)

' To draw arounded rectangle, add the following code:

theShape.CornerRadius = 12

theShape.FillStyle = FillStyle.Solid

theShape.FillColor = Color.Red

VB.NET我要用鼠标轨迹画一个矩形框 然后选中控件。就像星际和魔兽争霸里对部队单位的选中一样~等大神回答

这个类继承自Panel,把它加到你的项目里面,先运行一下,然后从工具箱里把它拖到窗体上,然后再向里面添加其它控件就可以了,支持Shift加选,Alt减选

Imports System.Linq

Imports System.Collections

Public Class MyPanel

Inherits Panel

' 选择模式,相交还是包含

Enum SelectMode

Intersects

Contains

End Enum

Dim down As New Point(-1, -1)

Dim rect As Rectangle

Dim selected As New List(Of Control)

Dim editting As IEnumerable(Of Control)

Dim mode As SelectMode = SelectMode.Contains

Dim shift, alt As Boolean

Public Sub New()

Me.DoubleBuffered = True

End Sub

Protected Overrides Sub OnMouseDown(e As MouseEventArgs)

MyBase.OnMouseDown(e)

down = e.Location

editting = selected.ToArray().ToList()

OnMouseMove(e)

End Sub

Protected Overrides Sub OnMouseMove(e As MouseEventArgs)

MyBase.OnMouseMove(e)

If e.Button = Windows.Forms.MouseButtons.Left Then

Dim loc As New Point(Math.Min(down.X, e.X), Math.Min(down.Y, e.Y))

Dim size As New Size(Math.Abs(down.X - e.X), Math.Abs(down.Y - e.Y))

rect = New Rectangle(loc, size)

Dim cs As New List(Of Control)

For Each c In Controls

cs.Add(c)

Next

Dim a = cs.Where(Function(n As Control) (mode = SelectMode.Contains And rect.Contains(n.Bounds)) Or (mode = SelectMode.Intersects And rect.IntersectsWith(n.Bounds)))

If shift Then editting = a.Union(selected) Else If alt Then editting = selected.Except(a) Else editting = a

Invalidate()

End If

End Sub

Protected Overrides Sub OnMouseUp(e As MouseEventArgs)

MyBase.OnMouseUp(e)

down = New Point(-1, -1)

selected = editting.ToList()

editting = Nothing

Invalidate()

End Sub

Protected Overrides Function ProcessKeyPreview(ByRef m As Message) As Boolean

Dim KeyCode As Keys = CInt(m.WParam) And CInt(Keys.KeyCode)

Dim d As Boolean

If m.Msg = H100 Or m.Msg = H104 Then d = True Else If m.Msg = H101 Or m.Msg = H105 Then d = False Else Return MyBase.ProcessKeyPreview(m)

If KeyCode = Keys.ShiftKey Then

shift = d

ElseIf KeyCode = Keys.Menu Then

alt = d

End If

Return MyBase.ProcessKeyPreview(m)

End Function

Protected Overrides Sub OnPaint(e As PaintEventArgs)

MyBase.OnPaint(e)

For Each c As Control In IIf(editting Is Nothing, selected, editting)

e.Graphics.DrawRectangle(New Pen(Color.Gray) With {.DashStyle = Drawing2D.DashStyle.DashDot}, c.Left - 1, c.Top - 1, c.Width + 1, c.Height + 1)

Next

If (down.X  0) Then e.Graphics.DrawRectangle(New Pen(Color.Gray) With {.DashStyle = Drawing2D.DashStyle.DashDot}, rect)

End Sub

End Class

在vb.net中,矩形只能从左向右画么

对于VB来说,其实是无所谓左右的。它只是把参数传递给底层的绘图接口而已。

对于底层接口来说,绘制矩形是可以有方向的。可以把四个参数对调就反过来了。

vb.net画一个矩形图片的代码

g = Me.picDisplay.CreateGraphics

Dim mybrush As Brush = New SolidBrush(Map_Empty_Color)

Dim rect2 As System.Drawing.Rectangle = New System.Drawing.Rectangle(0, 0, Map_Width, Map_Height)

g.FillRectangle(mybrush, rect2)


网站栏目:vbnet画矩形 vb画矩形程序代码
本文URL:http://bjjierui.cn/article/dogshcs.html

其他资讯