Dynamically creating textbox on panel scroll in vb.net - 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

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?

Vb.net Change single line font and color of text in textbox

I am making a function which can check strength of password. I have a problem to change single line text font and color. I know that I change text color and font for whole textbox, but is that an option to change only text font and color for single line of text in textbox?
Code:
Function Checker(password)
Dim i, l, c, k As Byte
Dim array() As Char = password.ToCharArray()
For i = 0 To array.Length - 1
If Char.IsUpper(array(i)) Then
c += 1
ElseIf Char.IsLower(array(i)) Then
l += 1
ElseIf Char.IsNumber(array(i)) Then
k += 1
ElseIf Char.IsSymbol(array(i)) Then
i += 1
End If
Next
If i >= 2 And k >= 3 And 2 >= 1 And c >= 2 And password.Length >= 6 Then
pnlCheckPass.txtChcekPass.Font = New Font("Microsoft YaHei UI", 10)
pnlCheckPass.txtChcekPass.ForeColor = Color.DarkGreen
pnlCheckPass.txtChcekPass.Text = " - Very strong password"
ElseIf k >= 3 And l >= 2 And c >= 2 And i >= 2 And password.Length >= 6 Then
pnlCheckPass.txtChcekPass.ForeColor = Color.Green
pnlCheckPass.txtChcekPass.Font = New Font("Microsoft YaHei UI", 10)
pnlCheckPass.txtChcekPass.Text = " - Strong password"
ElseIf k >= 2 And i >= 1 And c >= 1 And password.Length >= 6 Then
pnlCheckPass.txtChcekPass.Font = New Font("Microsoft YaHei UI", 10)
pnlCheckPass.txtChcekPass.ForeColor = Color.Orange
pnlCheckPass.txtChcekPass.Text = " - Medium password"
ElseIf k = 1 And i >= 1 And password.Length = 4 Then
pnlCheckPass.txtChcekPass.BackColor = Color.Red
pnlCheckPass.txtChcekPass.Font = New Font("Microsoft YaHei UI", 10)
pnlCheckPass.txtChcekPass.Text = " - Weak password"
ElseIf k = 1 Then
pnlCheckPass.txtChcekPass.ForeColor = Color.DarkRed
pnlCheckPass.txtChcekPass.Font = New Font("Microsoft YaHei UI", 10)
pnlCheckPass.txtChcekPass.Text = " - Very weak password"
Else
pnlCheckPass.txtChcekPass.ForeColor = Color.IndianRed
pnlCheckPass.txtChcekPass.Font = New Font("Microsoft YaHei UI", 10)
pnlCheckPass.txtChcekPass.Text = " - Blank password"
End If
Return pnlCheckPass.txtChcekPass.Text
End Function
(Explanations:)
pnlCheckPass - is form where i have a textbox

How to break pdf page in itextsharp pdf

I have written the following code to generate pdf:
path = Server.MapPath("PDF-Files")
filename = path + "/mydata.pdf"
document = New iTextSharp.text.Document(iTextSharp.text.PageSize.A4, 5.0F, 5.0F, 5.0F, 5.0F)
Dim bfTimes As BaseFont
Dim times As iTextSharp.text.Font
bfTimes = BaseFont.CreateFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, False)
times = New iTextSharp.text.Font(bfTimes, 8, iTextSharp.text.Font.NORMAL)
Dim writer As PdfWriter
writer = PdfWriter.GetInstance(document, New FileStream(filename, FileMode.Create))
Dim ev As New itsEvents
writer.PageEvent = ev
If document.IsOpen Then
document.Close()
End If
document.Open()
Dim spacing As Integer
spacing = 0
Dim curY, lineHeight As Double
curY = document.Top
lineHeight = 0
Const maxPerLine As Integer = 3
For k As Integer = 0 To ds.Tables(0).Rows.Count - 1
Dim table As PdfPTable
table = New PdfPTable(3)
table.DefaultCell.Border = iTextSharp.text.Rectangle.NO_BORDER
table.TotalWidth = 200.0F
table.LockedWidth = True
Dim cell As PdfPCell
cell = New PdfPCell()
cell.AddElement(New iTextSharp.text.Paragraph(ds.Tables(0).Rows(k)("id").ToString(), times))
cell.AddElement(New iTextSharp.text.Paragraph(ds.Tables(0).Rows(k)("name").ToString() + " " + dsLabelTemp.Tables(0).Rows(k)("city").ToString() + "(" + dsLabelTemp.Tables(0).Rows(k)("post").ToString() + ")", times))
cell.AddElement(New iTextSharp.text.Paragraph(ds.Tables(0).Rows(k)("userpersonal").ToString(), times))
cell.Colspan = 3
cell.HorizontalAlignment = 0
cell.Border = iTextSharp.text.Rectangle.NO_BORDER
cell.Padding = 20.0F
table.AddCell(cell)
table.WriteSelectedRows(0, -1, document.Left + spacing, curY, writer.DirectContent)
spacing = spacing + 200
lineHeight = Math.Max(lineHeight, table.TotalHeight)
If 0 = (k + 1) Mod maxPerLine Then
curY = curY - lineHeight
spacing = 0
lineHeight = 0
End If
Next
document.Close()
ShowPdf(filename)
When above code execute in perfect manner and gives the output but it is not showing the if page 1 completed .
In above image you can check that it is not showing full records.
I want to break the page if the page is full or increase the page hight.
How can i transfer data to second page if my 1st page is full ??
I got the solution.
Below is my new code:
Dim table As PdfPTable
table = New PdfPTable(4)
table.DefaultCell.Border = iTextSharp.text.Rectangle.NO_BORDER
table.TotalWidth = 400.0F
table.LockedWidth = True
For k As Integer = 0 To ds.Tables(0).Rows.Count - 1
Dim cell As PdfPCell
cell = New PdfPCell()
cell.AddElement(New iTextSharp.text.Paragraph(ds.Tables(0).Rows(k)("id").ToString(), times))
cell.AddElement(New iTextSharp.text.Paragraph(ds.Tables(0).Rows(k)("name").ToString() + " " + dsLabelTemp.Tables(0).Rows(k)("city").ToString() + "(" + dsLabelTemp.Tables(0).Rows(k)("post").ToString() + ")", times))
cell.AddElement(New iTextSharp.text.Paragraph(ds.Tables(0).Rows(k)("userpersonal").ToString(), times))
cell.Colspan = 1
cell.HorizontalAlignment = 0
cell.Border = iTextSharp.text.Rectangle.NO_BORDER
cell.Padding = 20.0F
table.AddCell(cell)
Next
document.Add(table)
document.Close()
ShowPdf(filename)

Problems adding DataTable as datasource in C1Report (VB) ComponentOne

I'm having troubles to assign a datasource to a code-generated c1report.
This is the datatable data.
This is the output result pdf view.
I'm using Visual Studio 2008 with ComponentOne 2009.
The result pdf file as not the correct data, only the titles repeated to bottom.
Then, this is the vb code:
Public Function DataTableToC1Report(ByVal dtDatos As DataTable, ByVal strTitulo As String) As C1.C1Report.C1Report
Dim c1r As New C1.C1Report.C1Report
'Inicia control
With c1r
'limpia fields existentes
.Clear()
'configura fuente para todos los controles
.Font.Name = "Tahoma"
.Font.Size = 8
End With
'Inicializar diseño
With c1r.Layout
.Orientation = C1.C1Report.OrientationEnum.Portrait
.Width = 6.5 * 1440 ' 8.5 - margen, en twips (aprox. son 567 twips por centímetro)
End With
'Crear encabezado y agregar field para titulo
Dim f As C1.C1Report.Field
With c1r.Sections(C1.C1Report.SectionTypeEnum.Header)
.Height = 1440
.Visible = True
.BackColor = Color.FromArgb(200, 200, 200)
f = .Fields.Add("FldTitle", strTitulo, 0, 0, 8000, 1440)
f.Font.Size = 24
f.Font.Bold = True
f.ForeColor = Color.FromArgb(0, 0, 100)
End With
'Crea footer de página
With c1r.Sections(C1.C1Report.SectionTypeEnum.PageFooter)
.Height = 500
.Visible = True
f = .Fields.Add("FldFtrLeft", """Generado el "" & Now", 0, 0, 4000, 300)
f.Calculated = True
f = .Fields.Add("FldFtrRight", """Página "" & Page & "" de "" & Pages", 4000, 0, 4000, 300)
f.Calculated = True
f.Align = C1.C1Report.FieldAlignEnum.RightTop
f.Width = c1r.Layout.Width - f.Left
f = .Fields.Add("FldLine", "", 0, 0, c1r.Layout.Width, 20)
f.LineSlant = C1.C1Report.LineSlantEnum.NoSlant
f.BorderStyle = C1.C1Report.BorderStyleEnum.Solid
f.BorderColor = Color.FromArgb(0, 0, 100)
End With
'Genera títulos con fields
With c1r.Sections(C1.C1Report.SectionTypeEnum.PageHeader)
.Height = 500
.Visible = True
Dim i As Integer = 0
Dim pIzq As Double = 0
Dim pArriba As Double = 50
Dim pAncho As Double = 800
Dim pAltura As Double = 300
For Each dc As DataColumn In dtDatos.Columns
c1r.Font.Bold = True
f = .Fields.Add("lblCol" & i.ToString, dc.ColumnName, pIzq, pArriba, pAncho, pAltura)
c1r.Font.Bold = False
f.Align = C1.C1Report.FieldAlignEnum.CenterMiddle
i += 1
pIzq += (pAncho + 100)
Next
f = .Fields.Add("FldLine", "", 0, 400, c1r.Layout.Width, 20)
f.LineSlant = C1.C1Report.LineSlantEnum.NoSlant
f.LineWidth = 50
f.BorderColor = Color.FromArgb(100, 100, 100)
End With
'Crea sección de detalle
With c1r.Sections(C1.C1Report.SectionTypeEnum.Detail)
Dim i As Integer = 0
Dim pIzq As Double = 0
Dim pArriba As Double = 0
Dim pAncho As Double = 800
Dim pAltura As Double = 300
.Height = 330
.Visible = True
For Each dc As DataColumn In dtDatos.Columns
c1r.Font.Bold = True
f = .Fields.Add("fldCol" & i.ToString, dc.ColumnName, pIzq, pArriba, pAncho, pAltura)
c1r.Font.Bold = False
f.Calculated = False 'agregar que permita verificar si la columna debe ser calculada y poner en True
f.CanGrow = False 'agregar que permita verificar si la columna puede crecer de tamaño
f.Align = C1.C1Report.FieldAlignEnum.CenterMiddle
'f.Width = c1r.Layout.Width - f.Left
f.Font.Size = 6
i += 1
pIzq += (pAncho + 100)
Next
f = .Fields.Add("FldLine", "", 0, 310, c1r.Layout.Width, 20)
f.LineSlant = C1.C1Report.LineSlantEnum.NoSlant
f.BorderStyle = C1.C1Report.BorderStyleEnum.Solid
f.BorderColor = Color.FromArgb(100, 100, 100)
End With
'Inicializar(DataSource)
With c1r.DataSource
'.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
' "Data Source=C:\...\ComponentOne Samples\Common\C1NWind.mdb;" & _
' "Persist Security Info=False"
'.RecordSource = "Employees"
.Recordset = dtDatos
End With
Return c1r
End Function
I think the issue is because you've set the Calculated property of the fields added in the Detail section to False. You need to set it to True in order to bind data to the fields.

ZedGraph - Force all graph panes to be the same size

I am using the ZedGraph control (zgc) to create individual stacked bar charts and display them in a single stacked column as shown in the image below.
The issue that I am having is that I have no control over the number of panes that are displayed in the control as this is determined by the number of items in a listbox. It seems that the default nature of the control allows the height of the graph panes to change depending on the number of panes that are displayed within the control.
The zgc is set to dock=fill within a panel control that is set to dock=fill within the form. I would like to force the graph panes to be a static height and when needed have a vertical scroll bar appear in the panel when the number of graph panes exceeds the height of the form. How can I go about achieving this? My code for creating and populating the zgc is posted below the image.
Private Sub CreateGraph(ByVal dat As Date)
Dim count As Integer = 0
Dim master As MasterPane = zgc.MasterPane
master.Fill = New Fill(Color.FromArgb(180, 180, 180), Color.FromArgb(180, 180, 180), 45.0F)
master.PaneList.Clear()
master.Title.IsVisible = True
master.Title.Text = "Workload for " & dat.ToShortDateString()
master.Margin.All = 10
master.InnerPaneGap = 5
master.IsCommonScaleFactor = False
For Each mach As String In lbMach.Items
rowCount = 0
Dim myPaneT As New GraphPane(New Rectangle(10, 10, 10, 10), "", "Time in Minutes", mach)
myPaneT.Fill.IsVisible = False
myPaneT.Chart.Fill = New Fill(Color.White, Color.White, 45.0F)
myPaneT.BaseDimension = 3.0F
myPaneT.XAxis.Title.IsVisible = False
myPaneT.XAxis.Scale.IsVisible = False
myPaneT.XAxis.Scale.Min = 0
myPaneT.XAxis.Scale.Max = (MeiSettings.WrkHrs * 60)
myPaneT.Legend.IsVisible = True
myPaneT.Border.IsVisible = False
myPaneT.Title.IsVisible = False
myPaneT.XAxis.MajorTic.IsOutside = False
myPaneT.XAxis.MinorTic.IsOutside = False
myPaneT.XAxis.MajorGrid.IsVisible = True
myPaneT.XAxis.MinorGrid.IsVisible = True
myPaneT.Margin.All = 1
If count = lbMach.Items.Count - 1 Then
myPaneT.XAxis.Title.IsVisible = True
myPaneT.XAxis.Scale.IsVisible = True
myPaneT.Margin.Bottom = 10
End If
If count > 0 Then
myPaneT.YAxis.Scale.IsSkipLastLabel = True
End If
myPaneT.YAxis.MinSpace = 20
myPaneT.Y2Axis.MinSpace = 20
Dim dt As DataTable = ItemsByMachineDT(mach, dat)
Dim myCurve As BarItem
If dt.Rows.Count > 0 Then
Dim profName As String = Nothing
Dim timeDur() As Double
For Each dr As DataRow In dt.Rows
If profName = dr("PRO").ToString() Then
timeDur = {((Convert.ToDouble(dr("QTY")) / Convert.ToDouble(dr("MPM"))))}
Else
timeDur = {((Convert.ToDouble(dr("QTY")) / Convert.ToDouble(dr("MPM")) + Convert.ToDouble(dr("Time"))))}
End If
myCurve = myPaneT.AddBar(dr("JOB").ToString & " - " & dr("PRO").ToString(), timeDur, Nothing, BarColor(rowCount))
If MeiSettings.IsGradient = True Then
myCurve.Bar.Fill = New Fill(BarColor(rowCount), Color.White, BarColor(rowCount), 90.0F)
Else
myCurve.Bar.Fill = New Fill(BarColor(rowCount), BarColor(rowCount), BarColor(rowCount), 90.0F)
End If
rowCount += 1
profName = dr("PRO").ToString()
Next
End If
myPaneT.YAxis.MajorTic.IsBetweenLabels = True
myPaneT.YAxis.Type = AxisType.Text
myPaneT.BarSettings.Type = BarType.Stack
myPaneT.BarSettings.Base = BarBase.Y
master.Add(myPaneT)
count += 1
Next
zgc.IsShowPointValues = True
Using g As Graphics = Me.CreateGraphics()
master.SetLayout(g, PaneLayout.SingleColumn)
master.AxisChange(g)
End Using
End Sub
to get control for each GraphPane :
GraphPane temp = zgc.MasterPane.PaneList.ElementAt(ind); //ind => index of the graphpane in zedgraphcontrol
to set static height n width ZedgraphControl :
zgc.Size = new Size(Width,Height);
to set visibility of scrollbar ZedgraphControl :
zgc.IsShowHScrollBar = true;
zgc.IsShowVScrollBar = true;