vb.net打印矩形 vb编程打印菱形

vb.net 打印功能

可以把数据导出到EXCEL,然后使用EXCEL进一步处理后使用。

创新互联自2013年起,先为天河等服务建站,天河等地企业,进行企业商务咨询服务。为天河企业网站制作PC+手机+微官网三网同步一站式服务解决您的所有建站问题。

也可以做成vb报表(VB自带有)。

先设置报表格式,打印时向报表传递数据就可以了。

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 打印问题

可以将打印机默认打印设置改为黑白打印,如果打印对象是RGB配色,打印机驱动转换为CMYK颜色时,黑色都是由彩色墨水组成的

2.可以试一下图片从一个标准灰度图片格式化而来,这样图片自身只有黑白色,也许可以

VB.NET如何能将文本框中的内容原样打印

Imports System.Drawing.Printing

Public Class Form1

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

Try

Dim PDoc As New PrintDocument

AddHandler PDoc.PrintPage, AddressOf Me.PText

PDoc.Print()

Catch ex As Exception

MessageBox.Show("error", ex.ToString)

End Try

End Sub

Private Sub PText(ByVal sender As Object, ByVal e As PrintPageEventArgs)

e.Graphics.DrawString(TextBox1.Text, New Font("Arial", 11, FontStyle.Regular), Brushes.Black, 120, 120)

e.HasMorePages = False

End Sub

End Class


当前文章:vb.net打印矩形 vb编程打印菱形
文章分享:http://ybzwz.com/article/hgsiec.html