Windows form control disappear during run time (VB.NET) - vb.net

I have created on Data Extractor application in Visual Studio 2019(VB.NET) which is scheduled to extract data from Access DB(updating by other software) file and convert to Text file in every 2 seconds. Meanwhile it also updates many controls of the form such as chart control, Progress Bar and Text box. I have published My application on .NET Framework 4.7.2
Issue:
Application is working Completely fine for almost an hour after initiation but its control started to fade and ultimately disappear after some time(As you can see in the image). Eventually it stopped responding and I have to close and reopen.
Ironically When I checked My text file during application under Hang condition, it was continuously updating with data from DB file. I suspected that code is performing its duty but Windows Form loses its aesthetics over the time. Why it is happening?
what could be the possible reason of occurrence? (I tried to clean the solution and built it again but gain no success)
I used CircularPeogressBar from https://github.com/RamsinChaabian/CircleProgressBar
Below is code from designer window
'CircularProgressBar1
'
Me.CircularProgressBar1.AccessibleRole = System.Windows.Forms.AccessibleRole.None
Me.CircularProgressBar1.AnimationFunction = WinFormAnimation.KnownAnimationFunctions.Liner
Me.CircularProgressBar1.AnimationSpeed = 0
Me.CircularProgressBar1.BackColor = System.Drawing.Color.Transparent
Me.CircularProgressBar1.Font = New System.Drawing.Font("Microsoft Sans Serif", 72.0!, System.Drawing.FontStyle.Bold)
Me.CircularProgressBar1.ForeColor = System.Drawing.Color.FromArgb(CType(CType(64, Byte), Integer), CType(CType(64, Byte), Integer), CType(CType(64, Byte), Integer))
Me.CircularProgressBar1.InnerColor = System.Drawing.Color.Transparent
Me.CircularProgressBar1.InnerMargin = 2
Me.CircularProgressBar1.InnerWidth = -1
Me.CircularProgressBar1.Location = New System.Drawing.Point(313, 132)
Me.CircularProgressBar1.MarqueeAnimationSpeed = 0
Me.CircularProgressBar1.Maximum = 60
Me.CircularProgressBar1.Name = "CircularProgressBar1"
Me.CircularProgressBar1.OuterColor = System.Drawing.Color.FromArgb(CType(CType(87, Byte), Integer), CType(CType(87, Byte), Integer), CType(CType(87, Byte), Integer))
Me.CircularProgressBar1.OuterMargin = -25
Me.CircularProgressBar1.OuterWidth = 25
Me.CircularProgressBar1.ProgressColor = System.Drawing.Color.Cyan
Me.CircularProgressBar1.ProgressWidth = 20
Me.CircularProgressBar1.SecondaryFont = New System.Drawing.Font("Microsoft Sans Serif", 36.0!)
Me.CircularProgressBar1.Size = New System.Drawing.Size(156, 156)
Me.CircularProgressBar1.StartAngle = -90
Me.CircularProgressBar1.Step = 1
Me.CircularProgressBar1.SubscriptColor = System.Drawing.Color.Transparent
Me.CircularProgressBar1.SubscriptMargin = New System.Windows.Forms.Padding(10, -35, 0, 0)
Me.CircularProgressBar1.SubscriptText = ""
Me.CircularProgressBar1.SuperscriptColor = System.Drawing.Color.Transparent
Me.CircularProgressBar1.SuperscriptMargin = New System.Windows.Forms.Padding(10, 35, 0, 0)
Me.CircularProgressBar1.SuperscriptText = ""
Me.CircularProgressBar1.TabIndex = 24
Me.CircularProgressBar1.TextMargin = New System.Windows.Forms.Padding(8, 8, 0, 0)
- Do I have to code entire CircularProgressBar Control to get rid of this issue or is there a way out available to tackle this problem?
- If proper dispose is the issue then how we can dispose them efficiently without leaking graphics resources?

Related

GMAP Control ".NET is not a member of 'GMapControl'"

I am getting solution errors when trying to run my application using the GmapControl package. Deleted the lines with errors does not seem to affect the application in any way but allows me to run the application, shortly after a while of debugging the lines reappear in the designer.vb file and the errors return.
Me.GMap.Bearing = 0!
Me.GMap.CanDragMap = True
Me.GMap.Dock = System.Windows.Forms.DockStyle.Fill
Me.GMap.EmptyTileColor = System.Drawing.Color.Navy
Me.GMap.GrayScaleMode = False
Me.GMap.HelperLineOption = GMap.NET.WindowsForms.HelperLineOptions.DontShow 'Error Line
Me.GMap.LevelsKeepInMemory = 5
Me.GMap.Location = New System.Drawing.Point(3, 3)
Me.GMap.MarkersEnabled = True
Me.GMap.MaxZoom = 2
Me.GMap.MinZoom = 2
Me.GMap.MouseWheelZoomEnabled = True
Me.GMap.MouseWheelZoomType = GMap.NET.MouseWheelZoomType.MousePositionAndCenter 'Error Line
Me.GMap.Name = "GMap"
Me.GMap.NegativeMode = False
Me.GMap.PolygonsEnabled = True
Me.GMap.RetryLoadTile = 0
Me.GMap.RoutesEnabled = True
Me.GMap.ScaleMode = GMap.NET.WindowsForms.ScaleModes.[Integer] 'Error Line
Me.GMap.SelectedAreaFillColor = System.Drawing.Color.FromArgb(CType(CType(33, Byte), Integer), CType(CType(65, Byte), Integer), CType(CType(105, Byte), Integer), CType(CType(225, Byte), Integer))
Me.GMap.ShowTileGridLines = False
Me.GMap.Size = New System.Drawing.Size(658, 455)
Me.GMap.TabIndex = 1
Me.GMap.Zoom = 0R
The problem is a name clash. GMap is a namespace and that is what .NET is a member of but you have added a GMapControl with the name GMap as well, so that is what the compiler is interpreting that name as. Notice how those lines all have Me.GMap on the left? The ones with GMap on the right are being interpreted as referring to that same GMapControl rather than the appropriate namespace. If you change the name of the control then the issue will go away.
You may need to either delete those lines first or edit them by hand afterwards though, because the rename may change the name of the namespace as well.
This is an example of why it's important to put some thought into your control and other names. If you use names that are descriptive in your specific scenario then name clashes are less likely.

Dropdown property setting for a Comboboxcol in datagridview in vb.net

I am facing a problem in VB.Net Winforms Application. I am using VS 2019.
The problem is the combobox column in Datagridview is not dropping down to show the list.
mDT and mDT1 are DataTables
ShowData is the name of the Datagridview
The properties in the designer for Show Data is shown below ( partially )
I tried various suggestions given in MSDN as well as here but am not successful. Might be because those might be old or are implemented differently in VS 2019.
The properties in the designer for Show Data is shown below ( partially )
[DGV Properties](https://i.stack.imgur.com/h60oO.jpg)
The Code
Dim mRow As DataRow
mDT = gDT_Structures.Copy()
mDT1 = New DataTable
mDT1.Columns.Add("PFID")
mDT1.AcceptChanges()
mRow = mDT1.NewRow()
mRow("PFID") = "PFID01"
mDT1.Rows.Add(mRow)
mDT1.AcceptChanges()
mRow = mDT1.NewRow()
mRow("PFID") = "PFID02"
mDT1.Rows.Add(mRow)
mDT1.AcceptChanges()
ShowData.Visible = True
ShowData.DataSource = mDT
'//Combobox column.
Dim ComboBoxcol = New DataGridViewComboBoxColumn()
ComboBoxcol.DataSource = mDT1
ComboBoxcol.Name = "PFID"
ComboBoxcol.ValueMember = "PFID"
ComboBoxcol.DisplayMember = "PFID"
ShowData.Columns.Add(ComboBoxcol)
For i = 0 To ShowData.Columns.Count() - 1
ShowData.Columns(i).ReadOnly = False
Next
ShowData.Select()
ShowData.Show()
The results View
[DGV Result](https://i.stack.imgur.com/l1Wi1.jpg)
Request guidance.
Thanks in Advance.

Line control in vb.net

I am new to .net world, got some work to convert the VB 6 code to VB.net
where OptionLine is a LINE Control & intCurrentControlTop is a integer variable
'Create line
Load Line(count)
Line(count).Y1 = 20
Line(count).Y2 = 30
Line(count).X1 = Line(0).X1
Line(count).X2 = Line(0).X2
Line(count).Visible = True
when I am trying to convert the above code using VS2005 wizard, it treated Line variable as Label and give me below version
Line As Microsoft.VisualBasic.Compatibility.VB6.LabelArray
Line.Load(count)
Line(count).Y1 = 20
Line(count).Y2 = 30
Line(count).X1 = Line(0).X1
Line(count).X2 = Line(0).X2
Line(count).Visible = True
Now when I am compiling , Error = X1 is not a member of System.Windows.Forms.Label
can some one help

How to resize image according to original image ration?

The white background after re-sizing the image using VB.net as shown below. I tried to change some values but failed.
Dim FileToResize As String = Server.MapPath("~/images/" & filename & FileUpload1.FileName)
Using originalBitmap As Bitmap = Bitmap.FromFile(FileToResize, True), newbmp As Bitmap = New Bitmap(200, 200)
Dim WidthVsHeightRatio = CDec(originalBitmap.Width) / CDec(originalBitmap.Height)
Using newg As Graphics = Graphics.FromImage(newbmp)
newg.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
newg.Clear(Color.White)
If WidthVsHeightRatio = 1D Then
newg.DrawImage(originalBitmap, 0, 0, 200, 200)
newg.Save()
ElseIf WidthVsHeightRatio < 1D Then 'Image is taller than wider
newg.DrawImage(originalBitmap, New RectangleF(New PointF((100 - (200 * WidthVsHeightRatio) / 2), 0), New SizeF(200 * WidthVsHeightRatio, 200.0F)))
newg.Save()
Else 'Image is wider than taller
Dim inverse As Double = Math.Pow(WidthVsHeightRatio, -1)
newg.DrawImage(originalBitmap, New RectangleF(New PointF(0, 100 - ((200 * inverse) / 2)), New SizeF(200.0F, 200 * inverse)))
newg.Save()
End If
End Using
newbmp.Save(Server.MapPath("~/images/" & "_th_" & filename & FileUpload1.FileName), System.Drawing.Imaging.ImageFormat.Jpeg)
NewsItem.ImageLink = filename & FileUpload1.FileName
NewsItem.smallimage = "_th_" & filename & FileUpload1.FileName
End Using
I did a bit of research recently for generating Image Thumbnails on the fly for an eCommerce site. I started off doing this myself generating a bitmap and then resizing etc. After problems with image size on disc and quality I looked in to http://imageresizing.net/ and I haven't looked back since. It can generate images from byte(), streams and physicals files all very quickly with one line of code:
ImageBuilder.Current.Build(New MemoryStream(bImage), sImageLocation + sFullFileName, New ResizeSettings("maxwidth=214&maxheight=238"))
I would definitely recommend this component rather than trying to reinvent the wheel...

vb.net crystal report view issues

I have a vb.net application that has a list of reports that you can select from.
When you select a report it loads the data and displays the report in the Crystal Report Viewer. However, The report display is way to big and the only way to resize it is to restore down the screen and then restore it to full screen. The scroll bars are only visible after you restore the page down and up.
The generated code for the viewer is as follows.
Me.CrystalReportViewer1.ActiveViewIndex = -1
Me.CrystalReportViewer1.AutoValidate = System.Windows.Forms.AutoValidate.EnablePreventFocusChange
Me.CrystalReportViewer1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.CrystalReportViewer1.Cursor = System.Windows.Forms.Cursors.Arrow
Me.CrystalReportViewer1.DisplayBackgroundEdge = False
Me.CrystalReportViewer1.Dock = System.Windows.Forms.DockStyle.Fill
Me.CrystalReportViewer1.EnableDrillDown = False
Me.CrystalReportViewer1.Location = New System.Drawing.Point(230, 0)
Me.CrystalReportViewer1.Name = "CrystalReportViewer1"
Me.CrystalReportViewer1.SelectionFormula = ""
Me.CrystalReportViewer1.ShowCloseButton = False
Me.CrystalReportViewer1.ShowGroupTreeButton = False
Me.CrystalReportViewer1.ShowRefreshButton = False
Me.CrystalReportViewer1.ShowTextSearchButton = False
Me.CrystalReportViewer1.Size = New System.Drawing.Size(517, 715)
Me.CrystalReportViewer1.TabIndex = 1
Me.CrystalReportViewer1.ToolPanelView = CrystalDecisions.Windows.Forms.ToolPanelViewType.None
Me.CrystalReportViewer1.ViewTimeSelectionFormula = ""
I am calling it like this:
Dim rpt As String
rpt = ListBox1.Items(ListBox1.SelectedIndex)
If Not CrystalReportViewer1.ReportSource Is Nothing Then CrystalReportViewer1.ReportSource.dispose()
Select Case rpt
Case "Scoot"
myreport = New graduation
LoadDatabaseInfo(myreport)
myreport.SetParameterValue("doop", indrno.Text)
'myreport.SetParameterValue("dte", indate.Value)
myreport.SetParameterValue("name", txb.Text)
CrystalReportViewer1.ReportSource = myreport
CrystalReportViewer1.Refresh()
CrystalReportViewer1.Zoom(55)
How do I fix This.. Thank you so much
Rather than zooming to 55 percent, try using a value of 1 to fit to the width of the page or 2 to fit in the page (from MSDN).
I was able to accomplish my resizing needs by setting the height and width properties of the window to set pixel values.
i.e.
CrystalReportViewer.Width = 1100
CrystalReportViewer.Height = 1200
It takes some playing around to get your values correct but this worked and I didn't have any zooming issues.