
正文
vb.net两个矩形框 vb边框
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
vb:在picture上面画两个矩形怎么画
用Picture1.Line(始点)-(终点),颜色,B 来画,比如
Picture1.Line(100,100)-(900,900),,B
在Picture控件中画一个始点为(100,100),终点(900,900)的地方画一个矩形
在始点里面的(100,100)相当于,X为100,Y为100的地方,终点X为900,Y为900的地方
相关问答
Q1: 如何改变vb.net程序的边框样式?
如果要做漂亮的界面的话,我建议你用WPF来做。所有的控件都可以用模板来定义样式。
虚线的话,只需要定义一个矩形,设置一个属性就可以了。前提是,WPF应用程序只能用VS2008或者VS2010来做
Q2: VB 求算法 两个矩形重叠部分
假定第一个矩形的坐标为x1,y1,宽高为w1,h1,第二个矩形的坐标为x2,y2,宽高为w2,h2:
If X2 X1 And X2 X1 + w1 And Y2 Y1 And Y2 Y1 + h1 Then
MsgBox "两个矩形有重叠,重叠区域:x=" X2 " y=" Y2 " w=" X1 + w1 - X2 " h=" Y1 + h1 - Y2
ElseIf X1 X2 And X1 X2 + w2 And Y2 Y1 And Y2 Y1 + h1 Then
MsgBox "两个矩形有重叠,重叠区域:x=" X1 " y=" Y2 " w=" X2 + w2 - X1 " h=" Y1 + h1 - Y2
ElseIf X2 X1 And X2 X1 + w1 And Y1 Y2 And Y1 Y2 + h2 Then
MsgBox "两个矩形有重叠,重叠区域:x=" X2 " y=" Y1 " w=" X1 + w1 - X2 " h=" Y2 + h2 - Y1
ElseIf X1 X2 And X1 X2 + w2 And Y1 Y2 And Y1 Y2 + h2 Then
MsgBox "两个矩形有重叠,重叠区域:x=" X1 " y=" Y1 " w=" X2 + w2 - X1 " h=" Y2 + h2 - Y1
Else
MsgBox "两个矩形没有重叠"
End If
Q3: 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
Q4: vb.net 画图对象问题
参考一下下面这段代码vb.net两个矩形框:
‘ 首先picturebox1 加载一张图像
FolderBrowserDialog1.Description = "选择图片文件夹导入图片"
FolderBrowserDialog1.ShowDialog()
path = FolderBrowserDialog1.SelectedPath()
If path = "" Then Return
strSrcFile = Dir(path "\*.tif")
PictureBox1.Image = Image.FromFile(path "\" strSrcFile)
’ 然后再在picturebox1中用graphic画图而不清空原图像
' 建立一个画图对象
Dim g As Graphics = Me.PictureBox1.CreateGraphics
‘ 定义画笔
Dim myPen As System.Drawing.Pen = New System.Drawing.Pen(Color.Blue)
’ 画出矩形框并且填充颜色(颜色保持50%的透明度vb.net两个矩形框,使得下面原来的图片背景能看得到)
g.DrawRectangle(myPen, New System.Drawing.Rectangle(50, 50, 30, 20))
g.FillRectangle(New SolidBrush(Color.FromArgb(50, Color.YellowGreen)), New System.Drawing.Rectangle(50, 50, 30, 20))
' 最后释放画图对象
g.Dispose()
效果大致如下图所示:
关于vb.net两个矩形框和vb边框的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。






