Vb.net custom tab controls - vb.net

what are some good tab control components out there for free. I have found the Krypton Navigator, but it isnt free. Others don't have the properties I need. Are there any good free tab controls with these properties:
tab page:
.backgroundimage
.image(on tab)
.color(on tab)
tabcontrol:
.selectedpage
.tabshape
.tabsizing(fixed,autosize,etc.)

Yes, there are many custom tab controls, this is one (VB.NET):
Imports System.Drawing.Drawing2D
Class DotNetBarTabcontrol
Inherits TabControl
Sub New()
SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.ResizeRedraw Or ControlStyles.UserPaint Or ControlStyles.DoubleBuffer, True)
DoubleBuffered = True
SizeMode = TabSizeMode.Fixed
ItemSize = New Size(44, 136)
End Sub
Protected Overrides Sub CreateHandle()
MyBase.CreateHandle()
Alignment = TabAlignment.Left
End Sub
Function ToPen(ByVal color As Color) As Pen
Return New Pen(color)
End Function
Function ToBrush(ByVal color As Color) As Brush
Return New SolidBrush(color)
End Function
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
Dim B As New Bitmap(Width, Height)
Dim G As Graphics = Graphics.FromImage(B)
Try : SelectedTab.BackColor = Color.White : Catch : End Try
G.Clear(Color.White)
G.FillRectangle(New SolidBrush(Color.FromArgb(246, 248, 252)), New Rectangle(0, 0, ItemSize.Height + 4, Height))
'G.DrawLine(New Pen(Color.FromArgb(170, 187, 204)), New Point(Width - 1, 0), New Point(Width - 1, Height - 1)) 'comment out to get rid of the borders
'G.DrawLine(New Pen(Color.FromArgb(170, 187, 204)), New Point(ItemSize.Height + 1, 0), New Point(Width - 1, 0)) 'comment out to get rid of the borders
'G.DrawLine(New Pen(Color.FromArgb(170, 187, 204)), New Point(ItemSize.Height + 3, Height - 1), New Point(Width - 1, Height - 1)) 'comment out to get rid of the borders
G.DrawLine(New Pen(Color.FromArgb(170, 187, 204)), New Point(ItemSize.Height + 3, 0), New Point(ItemSize.Height + 3, 999))
For i = 0 To TabCount - 1
If i = SelectedIndex Then
Dim x2 As Rectangle = New Rectangle(New Point(GetTabRect(i).Location.X - 2, GetTabRect(i).Location.Y - 2), New Size(GetTabRect(i).Width + 3, GetTabRect(i).Height - 1))
Dim myBlend As New ColorBlend()
myBlend.Colors = {Color.FromArgb(232, 232, 240), Color.FromArgb(232, 232, 240), Color.FromArgb(232, 232, 240)}
myBlend.Positions = {0.0F, 0.5F, 1.0F}
Dim lgBrush As New LinearGradientBrush(x2, Color.Black, Color.Black, 90.0F)
lgBrush.InterpolationColors = myBlend
G.FillRectangle(lgBrush, x2)
G.DrawRectangle(New Pen(Color.FromArgb(170, 187, 204)), x2)
G.SmoothingMode = SmoothingMode.HighQuality
Dim p() As Point = {New Point(ItemSize.Height - 3, GetTabRect(i).Location.Y + 20), New Point(ItemSize.Height + 4, GetTabRect(i).Location.Y + 14), New Point(ItemSize.Height + 4, GetTabRect(i).Location.Y + 27)}
G.FillPolygon(Brushes.White, p)
G.DrawPolygon(New Pen(Color.FromArgb(170, 187, 204)), p)
If ImageList IsNot Nothing Then
Try
If ImageList.Images(TabPages(i).ImageIndex) IsNot Nothing Then
G.DrawImage(ImageList.Images(TabPages(i).ImageIndex), New Point(x2.Location.X + 8, x2.Location.Y + 6))
G.DrawString(" " & TabPages(i).Text, Font, Brushes.DimGray, x2, New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Center})
Else
G.DrawString(TabPages(i).Text, New Font(Font.FontFamily, Font.Size, FontStyle.Bold), Brushes.DimGray, x2, New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Center})
End If
Catch ex As Exception
G.DrawString(TabPages(i).Text, New Font(Font.FontFamily, Font.Size, FontStyle.Bold), Brushes.DimGray, x2, New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Center})
End Try
Else
G.DrawString(TabPages(i).Text, New Font(Font.FontFamily, Font.Size, FontStyle.Bold), Brushes.DimGray, x2, New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Center})
End If
G.DrawLine(New Pen(Color.FromArgb(200, 200, 250)), New Point(x2.Location.X - 1, x2.Location.Y - 1), New Point(x2.Location.X, x2.Location.Y))
G.DrawLine(New Pen(Color.FromArgb(200, 200, 250)), New Point(x2.Location.X - 1, x2.Bottom - 1), New Point(x2.Location.X, x2.Bottom))
Else
Dim x2 As Rectangle = New Rectangle(New Point(GetTabRect(i).Location.X - 2, GetTabRect(i).Location.Y - 2), New Size(GetTabRect(i).Width + 3, GetTabRect(i).Height + 1))
G.FillRectangle(New SolidBrush(Color.FromArgb(246, 248, 252)), x2)
G.DrawLine(New Pen(Color.FromArgb(170, 187, 204)), New Point(x2.Right, x2.Top), New Point(x2.Right, x2.Bottom))
If ImageList IsNot Nothing Then
Try
If ImageList.Images(TabPages(i).ImageIndex) IsNot Nothing Then
G.DrawImage(ImageList.Images(TabPages(i).ImageIndex), New Point(x2.Location.X + 8, x2.Location.Y + 6))
G.DrawString(" " & TabPages(i).Text, Font, Brushes.DimGray, x2, New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Center})
Else
G.DrawString(TabPages(i).Text, Font, Brushes.DimGray, x2, New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Center})
End If
Catch ex As Exception
G.DrawString(TabPages(i).Text, Font, Brushes.DimGray, x2, New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Center})
End Try
Else
G.DrawString(TabPages(i).Text, Font, Brushes.DimGray, x2, New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Center})
End If
End If
Next
e.Graphics.DrawImage(B.Clone, 0, 0)
G.Dispose() : B.Dispose()
End Sub
End Class
How to use:
Create a new class then paste the code.
Save your project or debug it, then you will see the new tab page in the toolbox.
Enjoy you new awesome tab page.

Related

Label overlapping in pie chart

With Chart2
.Series.Clear()
.Titles.Clear()
.Series.Add("Series1")
End With
Dim series As Series = Chart2.Series("Series1")
series.ChartType = SeriesChartType.Pie
Chart2.DataSource = dt
With Chart2
.ChartAreas(0).Area3DStyle.Enable3D = True
.Series(0).XValueMember = "AccountName"
.Series(0).YValueMembers = "PolicyAmount"
.Series(0).IsValueShownAsLabel = True
.Series(0).Label = "(#VALY) #PERCENT"
.Series(0).LegendText = "#VALX (#VALY)(#PERCENT)"
.Series(0)("PieLabelStyle") = "inside"
.Series(0).Font = New Font("Segoe UI", 9, FontStyle.Bold)
'.Series(0).LabelForeColor = Color.White
.Titles(0).Font = New Font("Segoe UI", 10, FontStyle.Bold)
.Legends(0).Font = New Font("Segoe UI", 9, FontStyle.Bold)
End With
Is there a property which can arrange these labels within the coloured area. is there a angle property or like something m i missing?

PrintPreview is good, but prints empty

I'm adding a printing feature to my program. In print preview it shows all the data to be printed but it prints empty on paper.
Image is provided below
1st Preview
PrintPreview
This the code in PrintDocument1:
Private Sub PrintDocument1_PrintPage(sender As Object, e As Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
Try
If numpages = 1 Then
'e.Graphics.DrawRectangle(Pens.Red, e.MarginBounds)
e.Graphics.DrawString("Date: " & Date.Now.ToLongDateString, fon, Brushes.Black, 590, 260)
e.Graphics.DrawString("Time: " & Date.Now.ToLongTimeString, fon, Brushes.Black, 590, 285)
e.Graphics.DrawString("Republic of the Philippines", Headerfon, Brushes.Black, 295, 40)
e.Graphics.DrawString("Cebu Technologcial University", Headerfon, Brushes.Black, 270, 70)
e.Graphics.DrawString("Daanbantayan Campuse", Headerfon, Brushes.Black, 305, 100)
e.Graphics.DrawString("( SUC Level IV, AACCUP Accredited and ISO 9001 Certified )", fon2, Brushes.Black, 220, 130)
e.Graphics.DrawString("Agujo, Daanbantayan, Cebu", fon, Brushes.Black, 332, 150)
e.Graphics.DrawString("http://daanbantayan.ctu.edu.ph", fon2, Brushes.SteelBlue, 80, 190)
e.Graphics.DrawString("Email: ctudaanbantayan#yahoo.com", fon2, Brushes.SteelBlue, 560, 190)
e.Graphics.DrawString("Fax No. (032) 437-8523", fon2, Brushes.SteelBlue, 560, 210)
e.Graphics.DrawString("Telephone No. (032) 437-8526", fon2, Brushes.SteelBlue, 80, 210)
e.Graphics.DrawLine(Pens.Black, 800, 240, 55, 240)
e.Graphics.DrawLine(Pens.Black, 800, 244, 55, 244)
e.Graphics.DrawImage(PictureBox1.Image, 60.0F, 52.0F, 120.0F, 120.0F)
e.Graphics.DrawImage(PictureBox2.Image, 610.0F, 50.0F, 120.0F, 120.0F)
End If
line1:
e.Graphics.DrawImage(PictureBox3.Image, 50.0F, 1122.0F, 500.0F, 100.0F)
While PrintI <= Form12.timelog.Rows.Count - 2
Dim ColReaderSpace As Integer = 1
For Each GridCol As DataGridViewColumn In Form12.timelog.Columns
If ColHeaderY >= 1200 Then
If PrintI >= 1 Then
ColCellY = 50
ColHeaderY = 50
ColCellSpace = 52
numpages += 1
e.HasMorePages = True
e.Graphics.DrawImage(PictureBox3.Image, 50.0F, 1122.0F, 500.0F, 100.0F)
'GoTo line1
Exit Sub
End If
End If
line2:
Dim Rect As New Rectangle(x, ColHeaderY, xWidth, yHeight)
Dim strings As New StringFormat
strings.Alignment = StringAlignment.Center
strings.LineAlignment = StringAlignment.Center
e.Graphics.FillRectangle(Brushes.WhiteSmoke, Rect)
e.Graphics.DrawRectangle(Pens.Black, Rect)
e.Graphics.DrawString(GridCol.HeaderText, fon, Brushes.Black, Rect)
If ColReaderSpace = 8 Then
ColHeaderY += 20
End If
ColHeaderY += 20
ColReaderSpace += 2
Next GridCol
For k As Integer = 0 To 7
Dim Rec As New Rectangle(y, ColCellY, CellWidth, yHeight)
e.Graphics.DrawRectangle(Pens.Black, Rec)
e.Graphics.DrawString(Form12.timelog.Rows(PrintI).Cells(k).Value.ToString, fon, Brushes.Black, CellHeight, ColCellSpace)
If ColReaderSpace = 10 Then
ColCellY += 20
ColCellSpace += 20
End If
ColCellY += 20
ColCellSpace += 20
ColReaderSpace += 1
Next
e.HasMorePages = False
PrintI += 1
End While
Catch ex As Exception
MessageBox.Show(ex.Message & vbCrLf & vbCrLf & "Please Make Sure There is Data to print", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
e.Graphics.DrawImage(PictureBox3.Image, 50.0F, 1122.0F, 500.0F, 100.0F)
End Sub
This is the code in printing:
Private Sub print_Click(sender As Object, e As EventArgs) Handles print.Click
ColHeaderY = 320
ColCellY = 320
ColCellSpace = 320
PrintI = 0
numpages = 1
PrintDialog1.PrinterSettings = PrintDocument1.PrinterSettings
If PrintDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
PrintDocument1.PrinterSettings = PrintDialog1.PrinterSettings
End If
PrintPreviewDialog1.Document = PrintDocument1
PrintPreviewDialog1.TopMost = True
PrintPreviewDialog1.ShowDialog()
End Sub
I hope that someone can help me with this error.

Dynamically creating textbox on panel scroll in vb.net

Hi i am creating 10 text boxes and combo boxes as a row to populate a sales invoice screen. after user entering to the last text box dynamically created i am populating again 20 more rows and after user entering the 29th text box again i am creating 20 more rows and it goes untill 250 rows created, but i am stuck on which event should i write the code and serial number also i could not generate
Private Sub Panel1_Resize(sender As Object, e As System.EventArgs) Handles Panel1.Enter
Dim viewable As Boolean
If box5(9).Location.Y < Panel1.Height AndAlso box5(9).Location.Y + box5(9).Height > 0 Then
viewable = True
Panel1.HorizontalScroll.Visible = False
Dim x1 As Integer = 100
Dim y1 As Integer = 0
Dim MyLocationX As Integer = 175
Dim MyLocationY As Integer = 175
Dim k As Integer
For i As Integer = 0 To 90
For j As Integer = 11 To 90
box5(i) = New TextBox
box5(i).ReadOnly = True
box5(i).BackColor = Color.White
box5(i).Text = 10 + i
Next j
k = box5(i).Text
box5(i).Font = New Font("Times New Roman", 9)
box5(i).TabStop = False
box5(i).Location = New System.Drawing.Point(0, 200 + i * 20)
box5(i).Size = New System.Drawing.Size(55, 26.2)
box5(i).Multiline = True
AddHandler box5(i).TextChanged, AddressOf Qty_TextChanged
Panel1.Controls.Add(box5(i))
DropDownlist(i) = New ComboBox
DropDownlist(i).Name = (y1 + 1).ToString
DropDownlist(i).Location = New Point(55, 200 + i * 20)
DropDownlist(i).ImeMode = Windows.Forms.ImeMode.KatakanaHalf
DropDownlist(i).DropDownStyle = ComboBoxStyle.DropDown
DropDownlist(i).AutoCompleteSource = AutoCompleteSource.ListItems
DropDownlist(i).AutoCompleteMode = AutoCompleteMode.SuggestAppend
DropDownlist(i).Font = New Font("Times New Roman", 12)
DropDownlist(i).Size = New System.Drawing.Size(150, 50)
AddHandler DropDownlist(i).KeyDown, AddressOf dropdownsearch
AddHandler DropDownlist(i).GotFocus, AddressOf cbsearch
Panel1.Controls.Add(DropDownlist(i))
MyLocationY = MyLocationY + 60
y1 = y1 + 1
box6(i) = New TextBox
box6(i).BackColor = Color.White
box6(i).Font = New Font("Times New Roman", 12)
box6(i).Location = New System.Drawing.Point(199, 200 + i * 20)
box6(i).Size = New System.Drawing.Size(216, 22)
box6(i).ReadOnly = True
AddHandler box6(i).GotFocus, AddressOf combo_TextChanged1
Panel1.Controls.Add(box6(i))
Dim qty1(100) As Double
iname(i) = New TextBox
iname(i).Location = New System.Drawing.Point(412, 200 + i * 20)
iname(i).Size = New System.Drawing.Size(52, 22)
iname(i).Font = New Font("Times New Roman", 12)
Panel1.Controls.Add(iname(i))
AddHandler iname(i).LostFocus, AddressOf combo_TextChanged3
AddHandler iname(i).LostFocus, AddressOf combo_TextChanged66
AddHandler iname(i).LostFocus, AddressOf combo_TextChanged68
Dim rate1(100) As Double
exname1(i) = New TextBox
exname1(i).Location = New System.Drawing.Point(464, 200 + i * 20)
exname1(i).Size = New System.Drawing.Size(61, 22)
exname1(i).Font = New Font("Times New Roman", 12)
rate1(i) = Val(exname1(i).Text)
Panel1.Controls.Add(exname1(i))
box2(i) = New TextBox
box2(i).Location = New System.Drawing.Point(524, 200 + i * 20)
box2(i).Size = New System.Drawing.Size(70, 22)
box2(i).ReadOnly = False
box2(i).BackColor = Color.White
box2(i).Font = New Font("Times New Roman", 12)
Panel1.Controls.Add(box2(i))
gross(i) = New TextBox
gross(i).Location = New System.Drawing.Point(593, 200 + i * 20)
gross(i).Size = New System.Drawing.Size(85, 22)
gross(i).ReadOnly = False
gross(i).BackColor = Color.White
gross(i).Font = New Font("Times New Roman", 12)
Panel1.Controls.Add(gross(i))
disp(i) = New TextBox
disp(i).Location = New System.Drawing.Point(675, 200 + i * 20)
disp(i).Size = New System.Drawing.Size(45, 22)
disp(i).ReadOnly = False
disp(i).BackColor = Color.White
disp(i).Font = New Font("Times New Roman", 12)
Panel1.Controls.Add(disp(i))
net(i) = New TextBox
net(i).Location = New System.Drawing.Point(718, 200 + i * 20)
net(i).Size = New System.Drawing.Size(97, 22)
net(i).ReadOnly = False
net(i).BackColor = Color.White
net(i).Font = New Font("Times New Roman", 12)
Panel1.Controls.Add(net(i))
spc(i) = New TextBox
spc(i).Location = New System.Drawing.Point(814, 200 + i * 20)
spc(i).Size = New System.Drawing.Size(127, 22)
spc(i).ReadOnly = False
spc(i).BackColor = Color.White
spc(i).Font = New Font("Times New Roman", 12)
Panel1.Controls.Add(spc(i))
exdes(i) = New TextBox
exdes(i).Location = New System.Drawing.Point(939, 200 + i * 20)
exdes(i).Size = New System.Drawing.Size(170, 22)
exdes(i).ReadOnly = False
exdes(i).BackColor = Color.White
exdes(i).Font = New Font("Times New Roman", 12)
Panel1.Controls.Add(exdes(i))
fullfill(i) = New DateTimePicker
fullfill(i).Location = New System.Drawing.Point(1107, 200 + i * 20)
fullfill(i).Size = New System.Drawing.Size(100, 22)
fullfill(i).CustomFormat = "dd-MM-yy"
fullfill(i).Format = DateTimePickerFormat.Custom
fullfill(i).BackColor = Color.White
fullfill(i).Font = New Font("Times New Roman", 12)
Panel1.Controls.Add(fullfill(i))
If (String.IsNullOrEmpty(DropDownlist(i).Text)) Then
AddHandler DropDownlist(i).LostFocus, AddressOf combo_TextChanged
AddHandler DropDownlist(i).LostFocus, AddressOf combo_TextChanged2
Else
box6(i).Clear()
End If
Next i
Else
viewable = False
End If
End Sub

e.graphics.hasmorepages = true doesn't print on the next page VB.NET

I am having hard time printing multiple pages on print document. It keeps printing everything on the first page even though I have new page set up in my code. Please help. Here is my code:`
Private Sub PrintDocument1_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
Dim yTop As Single = e.MarginBounds.Top
Dim leftmargin = e.MarginBounds.Left
Dim MyPen As New Pen(Color.Black, 1)
Dim regFont = New Font("Arial", 10)
Dim smallFont = New Font("Arial", 8)
Dim xsFont = New Font("Arial", 6)
Dim micrFont = New Font("MICR", 10)
Dim myprintfont = New Font("Arial", 12)
Dim Bigfont = New Font("Arial", 14, FontStyle.Bold)
Dim BldFnt = New Font("Arial", 9, FontStyle.Bold)
Dim fCtr As New StringFormat
fCtr.Alignment = StringAlignment.Center
Dim frt As New StringFormat
frt.Alignment = StringAlignment.Near
Dim flft As New StringFormat
flft.Alignment = StringAlignment.Far
'Dim mrc As String = ""
Dim lpos As Integer = My.Settings.ChkLeft
Dim blackPen As New Pen(Color.Black, 1)
Dim y As Integer = 0
Dim mrc As String = ""
Dim p As Integer = 0
Dim j As Integer = 0
Dim ct As Integer = dgChecks.SelectedRows.Count
Static totaChecksPrinted As Integer
If totaChecksPrinted < dgChecks.SelectedRows.Count - 1 Then
For Each row As DataGridViewRow In dgChecks.SelectedRows
st = row.Cells("CheckNumber").Value
Dim strSQL1 As String
strSQL1 = "SELECT * FROM QryCheckPrint WHERE CheckNumber In( " & st & ")"
If HQCon.State = ConnectionState.Closed Then HQCon.Open()
Dim ccmda As New Data.SqlClient.SqlCommand(strSQL1, HQCon)
Dim drc2 As Data.SqlClient.SqlDataReader
Dim HasRows As Boolean = False
drc2 = ccmda.ExecuteReader
If drc2.HasRows Then
While drc2.Read
y += My.Settings.ChkTop
e.Graphics.DrawString(drc2.Item("CorpName"), Bigfont, Brushes.Black, lpos, y, frt)
e.Graphics.DrawString(drc2.Item("CheckNumber"), Bigfont, Brushes.Black, lpos + 640, y + 1, frt)
y += 40
e.Graphics.DrawString(drc2.Item("Date"), smallFont, Brushes.Black, lpos + 640, y + 6, frt)
e.Graphics.DrawString("Date", myprintfont, Brushes.Black, lpos + 580, y + 5, frt)
e.Graphics.DrawLine(blackPen, lpos + 620, y + 25, lpos + 730, y + 25)
y += 60
e.Graphics.DrawString("Pay to the", smallFont, Brushes.Black, lpos, y, frt)
y += 15
e.Graphics.DrawString("order of", smallFont, Brushes.Black, lpos + 10, y, frt)
e.Graphics.DrawString(drc2.Item("Name"), myprintfont, Brushes.Black, lpos + 90, y - 10, frt)
If Not IsDBNull(drc2.Item("Amount")) Then
e.Graphics.DrawString("$" & Format(drc2.Item("Amount"), "n2"), myprintfont, Brushes.Black, lpos + 640, y - 5, frt)
End If
y += 15
e.Graphics.DrawLine(blackPen, lpos + 50, y, lpos + 640, y)
e.Graphics.DrawLine(blackPen, lpos + 50, y + 30, lpos + 640, y + 30)
e.Graphics.DrawLine(blackPen, lpos + 640, y - 25, lpos + 640, y)
e.Graphics.DrawString("**" & Functions.AmountInWords(drc2.Item("Amount")) & "**", regFont, Brushes.Black, lpos + 100, y + 10, frt)
y += 40
e.Graphics.DrawString(drc2.Item("BankName"), smallFont, Brushes.Black, lpos, y, frt)
y += 15
e.Graphics.DrawString(drc2.Item("BankAddress"), smallFont, Brushes.Black, lpos, y, frt)
y += 15
e.Graphics.DrawString(drc2.Item("City") & " " & drc2.Item("State") & ", " & drc2.Item("Zip"), smallFont, Brushes.Black, lpos, y, frt)
mrc = "o" & drc2.Item("CheckNumber") & "o T" & drc2.Item("ABA") & "T" & drc2.Item("AccountNumber") & "o"
y += 30
e.Graphics.DrawString(drc2.Item("Description"), smallFont, Brushes.Black, lpos + 80, y, frt)
e.Graphics.DrawString("For", regFont, Brushes.Black, lpos + 30, y, frt)
e.Graphics.DrawString("By", regFont, Brushes.Black, lpos + 480, y, frt)
e.Graphics.DrawString(drc2.Item("StoreCode"), xsFont, Brushes.Black, lpos + 400, y, frt)
e.Graphics.DrawLine(blackPen, lpos + 30, y + 20, lpos + 440, y + 20)
e.Graphics.DrawLine(blackPen, lpos + 500, y + 20, lpos + 720, y + 20)
y = y + My.Settings.MicrPos
e.Graphics.DrawString(mrc, micrFont, Brushes.Black, lpos + 100, y, frt)
y = y + My.Settings.ChkBottom
j += 1
totaChecksPrinted += 1
End While
End If
drc2.Close()
ccmda = Nothing
If (y > e.MarginBounds.Bottom) Then 'Print new page
e.HasMorePages = True
y = 0
End If
Next
End If
If HQCon.State = ConnectionState.Open Then HQCon.Close()
End Sub`
Each time the PrintPage event is raised, you should print only the data that goes on that page. If you have more data to print, set HasMorePages to True and then Exit Sub. Then the PrintPage method will be called again for the next page. You will need to keep track of what you have already printed between pages somehow. Something like this:
'Class level variable perhaps
Dim pageNumberToPrint As Integer = 1
Private Sub PrintDocument1_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
'Print the data that goes on the current page (pageNumberToPrint)
If pageNumberToPrint = 1 Then
'Print page number 1
Else
If pageNumberToPrint = 2 Then
'Print page number 2
Else
'Print page number 3
End If
End If
'If you're at the end of the page, and still have more data to print
If (y > e.MarginBounds.Bottom) Then 'Print new page
e.HasMorePages = True
y = 0
pageNumberToPrint += 1
Exit Sub 'The PrintPage event handler will be raised again
End If
End Sub

3 way check box (toggle)

I have a custom 'toggle' (using ButterscotchTheme) and I am trying to add a 3rd option.
This is how it currently is: (cant post pictures due to being new, but here is links to the pictures)
I would like a third option. I have checked the theme code and it is done by Checkbox rules. And I know a Tricheckbox is a thing, I am just unsure how to get it to work. I did some research and was unable to figure it out in this situation.
Here is all the Themes toggle code:
Public Class ButterscotchToggle : Inherits Control
Private _check As Boolean
Public Property Checked As Boolean
Get
Return _check
End Get
Set(ByVal value As Boolean)
_check = value
Invalidate()
End Set
End Property
Sub New()
MyBase.New()
SetStyle(ControlStyles.UserPaint Or ControlStyles.ResizeRedraw Or ControlStyles.SupportsTransparentBackColor, True)
DoubleBuffered = True
BackColor = Color.Transparent
Size = New Size(80, 25)
End Sub
Protected Overrides Sub OnClick(ByVal e As EventArgs)
Checked = Not Checked
MyBase.OnClick(e)
End Sub
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
Dim b As Bitmap = New Bitmap(Width, Height)
Dim g As Graphics = Graphics.FromImage(b)
Dim outerrect As Rectangle = New Rectangle(0, 0, Width - 1, Height - 1)
Dim maininnerrect As Rectangle = New Rectangle(7, 7, Width - 15, Height - 15)
Dim buttonrect As New LinearGradientBrush(outerrect, Color.FromArgb(100, 90, 80), Color.FromArgb(48, 43, 39), 90S)
MyBase.OnPaint(e)
g.Clear(BackColor)
g.SmoothingMode = SmoothingMode.HighQuality
g.InterpolationMode = InterpolationMode.HighQualityBicubic
g.FillPath(New SolidBrush(Color.FromArgb(40, 37, 33)), RoundRect(outerrect, 5))
g.DrawPath(New Pen(Color.FromArgb(0, 0, 0)), RoundRect(outerrect, 5))
g.FillPath(New SolidBrush(Color.FromArgb(26, 25, 21)), RoundRect(maininnerrect, 3))
g.DrawPath(New Pen(Color.FromArgb(0, 0, 0)), RoundRect(maininnerrect, 3))
If Checked Then
g.FillPath(buttonrect, RoundRect(New Rectangle(3, 3, CInt((Width / 2) - 3), Height - 7), 7))
g.DrawString("ON", New Font("Segoe UI", 10, FontStyle.Bold), New SolidBrush(Color.FromArgb(246, 180, 12)), New Rectangle(2, 2, CInt((Width / 2) - 1), Height - 5), New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
Else
g.FillPath(buttonrect, RoundRect(New Rectangle(CInt((Width / 2) - 3), 3, CInt((Width / 2) - 3), Height - 7), 7))
g.DrawString("OFF", New Font("Segoe UI", 10, FontStyle.Bold), New SolidBrush(Color.FromArgb(246, 180, 12)), New Rectangle(CInt((Width / 2) - 2), 2, CInt((Width / 2) - 1), Height - 5), New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
End If
e.Graphics.DrawImage(b, New Point(0, 0))
g.Dispose() : b.Dispose()
End Sub
End Class
Any help would be greatly appreciated!
Theme downloaded from Butterscotch Theme GDI+
You would have to change that boolean property to an integer (or even better, create an enum):
Private _check As Integer
Public Property Checked As Integer
Get
Return _check
End Get
Set(ByVal value As Integer)
_check = value
Invalidate()
End Set
End Property
Change the OnClick behavior:
Protected Overrides Sub OnClick(ByVal e As EventArgs)
If Checked + 1 > 2 Then
Checked = 0
Else
Checked += 1
End If
MyBase.OnClick(e)
End Sub
and then adjust the drawing accordingly (placing the third option in the middle I'm guessing):
Select Case Checked
Case 0
g.FillPath(buttonrect, RoundRect(New Rectangle(CInt((Width / 2) - 3), 3, CInt((Width / 2) - 3), Height - 7), 7))
g.DrawString("OFF", New Font("Segoe UI", 10, FontStyle.Bold), New SolidBrush(Color.FromArgb(246, 180, 12)), New Rectangle(CInt((Width / 2) - 2), 2, CInt((Width / 2) - 1), Height - 5), New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
Case 1
g.FillPath(buttonrect, RoundRect(New Rectangle(3, 3, CInt((Width / 2) - 3), Height - 7), 7))
g.DrawString("ON", New Font("Segoe UI", 10, FontStyle.Bold), New SolidBrush(Color.FromArgb(246, 180, 12)), New Rectangle(2, 2, CInt((Width / 2) - 1), Height - 5), New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
Case 2
g.FillPath(buttonrect, RoundRect(New Rectangle((Width / 2) - (Width / 4), 3, CInt((Width / 2) - 3), Height - 7), 7))
g.DrawString("???", New Font("Segoe UI", 10, FontStyle.Bold), New SolidBrush(Color.FromArgb(246, 180, 12)), New Rectangle((Width / 2) - (Width / 4), 2, CInt((Width / 2) - 1), Height - 5), New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
End Select