[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

statusbar problem how do i update panel text and also display progress bar

Posted on 2004-10-23
5
Medium Priority
?
255 Views
Last Modified: 2010-04-24
i have the code below in an update form...

my problem is i dont think the text is going to the panel and displaying..at least i cant see it when its run...

my next question is how do i put a progressbar to show the downloaded files progress

(and have i dont this form right, ie is the code slopy or can it be better, im learning vb.net any help would be great)

Thx
Johnny
aka Pern

---- code ---
Public Class Update

    Private Sub Update_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        ''Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        ''Me.ClientSize = New System.Drawing.Size(232, 40)
        ''Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None
        ''Me.Name = "update"
        ''Me.ShowInTaskbar = False
        ''Me.Text = "Updater"
        ''Me.TransparencyKey = System.Drawing.SystemColors.Control
        ''Me.WindowState = System.Windows.Forms.FormWindowState.Minimized

        'Label1.Text = Me.ProductVersion
        TextBox1.Text = "This product version is: " & System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString 'Application.ProductVersion
        ListBox1.Items.Add("Version Major: " & System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.Major)
        ListBox1.Items.Add("Version Minor: " & System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.Minor)
        ListBox1.Items.Add("Version Build: " & System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.Build)
        ListBox1.Items.Add("Version Revision: " & System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.Revision)

        Dim Panel1_text As String
        Panel1_text = "Ready..."
        ''CreateMyStatusBar(Panel1_text)



        ' Create a StatusBar control.
        Dim statusBar1 As New StatusBar()
        ' Create two StatusBarPanel objects to display in the StatusBar.
        Dim panel1 As New StatusBarPanel()

        Dim panel2 As New StatusBarPanel()

        ' Display the first panel with a sunken border style.
        panel1.BorderStyle = StatusBarPanelBorderStyle.Sunken
        ' Initialize the text of the panel.
        ''panel1.Text = "Ready..."
        panel1.Text = Panel1_text
        ' Set the AutoSize property to use all remaining space on the StatusBar.
        panel1.AutoSize = StatusBarPanelAutoSize.Spring
        ' Display the second panel with a raised border style.
        panel2.BorderStyle = StatusBarPanelBorderStyle.Raised
        ' Create ToolTip text that displays the current time.
        panel2.ToolTipText = System.DateTime.Now.ToShortTimeString()
        ' Set the text of the panel to the current date.
        panel2.Text = System.DateTime.Today.ToLongDateString()
        ' Set the AutoSize property to size the panel to the size of the contents.
        panel2.AutoSize = StatusBarPanelAutoSize.Contents

        ' Display panels in the StatusBar control.
        statusBar1.ShowPanels = True

        ' Add both panels to the StatusBarPanelCollection of the StatusBar.            
        statusBar1.Panels.Add(panel1)
        statusBar1.Panels.Add(panel2)

        ' Add the StatusBar to the form.
        Me.Controls.Add(statusBar1)

        ''Panel1_text = "Ready...test"
        ''CreateMyStatusBar(Panel1_text)
        statusBar1.Panels(0).Text = "Downloading file ..."

        deleteFile("ArgoDragonEMailManager_Version.txt")

        Dim wc As New System.Net.WebClient()
        wc.DownloadFile("http://www.argodragonsoftware.info/Download/ArgoDragonEMailManager_Version.txt", _
                 "ArgoDragonEMailManager_Version.txt")
        statusBar1.Panels(0).Text = "Got file: ArgoDragonEMailManager_Version.txt"
        Dim strVersion, strPath As String
        ''Try
        'Dim uc As New Net.WebClient
        'uc.DownloadFile("http://router19.org:8080/updates/updater.txt", "updater.txt")
        If System.IO.File.Exists("ArgoDragonEMailManager_Version.txt") Then
            ''MsgBox("Exists!")
            statusBar1.Panels(0).Text = "File Exists: ArgoDragonEMailManager_Version.txt"
            FileOpen(2, "ArgoDragonEMailManager_Version.txt", OpenMode.Input) ', OpenAc
            strVersion = LineInput(2)
            TextBox2.Text = "" & strVersion
            FileClose(2)

        Else
            ''MsgBox("D'oh!")
            TextBox2.Text = "File not found or file was not downloaded"
        End If
        ''strPath = LineInput(2)
        'Shell("explorer.exe " & "http://www.router19.org/software.aspx", vbNormalFocus)
        ''Dim uc2 As Net.WebClient
        ''uc2.DownloadFile(strPath, "FirePanelXP.msi")
        ''Catch ex As Exception
        ''End Try

        statusBar1.Panels(0).Text = "Ready"
        wc.Dispose()

    End Sub
    Public Sub CreateMyStatusBar(ByVal Panel1_text As String)
        ' Create a StatusBar control.
        Dim statusBar1 As New StatusBar()
        ' Create two StatusBarPanel objects to display in the StatusBar.
        Dim panel1 As New StatusBarPanel()

        Dim panel2 As New StatusBarPanel()

        ' Display the first panel with a sunken border style.
        panel1.BorderStyle = StatusBarPanelBorderStyle.Sunken
        ' Initialize the text of the panel.
        ''panel1.Text = "Ready..."
        panel1.Text = Panel1_text
        ' Set the AutoSize property to use all remaining space on the StatusBar.
        panel1.AutoSize = StatusBarPanelAutoSize.Spring
        ' Display the second panel with a raised border style.
        panel2.BorderStyle = StatusBarPanelBorderStyle.Raised
        ' Create ToolTip text that displays the current time.
        panel2.ToolTipText = System.DateTime.Now.ToShortTimeString()
        ' Set the text of the panel to the current date.
        panel2.Text = System.DateTime.Today.ToLongDateString()
        ' Set the AutoSize property to size the panel to the size of the contents.
        panel2.AutoSize = StatusBarPanelAutoSize.Contents

        ' Display panels in the StatusBar control.
        statusBar1.ShowPanels = True

        ' Add both panels to the StatusBarPanelCollection of the StatusBar.            
        statusBar1.Panels.Add(panel1)
        statusBar1.Panels.Add(panel2)

        ' Add the StatusBar to the form.
        Me.Controls.Add(statusBar1)
    End Sub

End Class
0
Comment
Question by:Johnny
  • 2
  • 2
5 Comments
 
LVL 16

Expert Comment

by:burakiewicz
ID: 12391163
for the progress bar just add the progress bar control. for the text i think it is statusBar1.Panels(panel1).Text = "Downloading file ..."
if not i will check when i get home, at work right now
0
 

Author Comment

by:Johnny
ID: 12393303
ive done that in the code a few times heres one:

statusBar1.Panels(0).Text = "Got file: ArgoDragonEMailManager_Version.txt"

but i cant see it eitehr its NOT displaying or its going by to fast or i thought it maybe that do events thing that used to be in vb6. does vb.net have that?? how would you incriment the progress bar for downloading the file?

thx
Johnny
aka Pern
0
 
LVL 18

Expert Comment

by:armoghan
ID: 12397385
see this simple code it shows the panels and text in them, Also changing the 2nd panel's text on load

Public Class Form2
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents StatusBar1 As System.Windows.Forms.StatusBar
    Friend WithEvents StatusBarPanel1 As System.Windows.Forms.StatusBarPanel
    Friend WithEvents StatusBarPanel2 As System.Windows.Forms.StatusBarPanel
    Friend WithEvents StatusBarPanel3 As System.Windows.Forms.StatusBarPanel
    Friend WithEvents StatusBarPanel4 As System.Windows.Forms.StatusBarPanel
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.StatusBar1 = New System.Windows.Forms.StatusBar
        Me.StatusBarPanel1 = New System.Windows.Forms.StatusBarPanel
        Me.StatusBarPanel2 = New System.Windows.Forms.StatusBarPanel
        Me.StatusBarPanel3 = New System.Windows.Forms.StatusBarPanel
        Me.StatusBarPanel4 = New System.Windows.Forms.StatusBarPanel
        CType(Me.StatusBarPanel1, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.StatusBarPanel2, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.StatusBarPanel3, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.StatusBarPanel4, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.SuspendLayout()
        '
        'StatusBar1
        '
        Me.StatusBar1.Location = New System.Drawing.Point(0, 244)
        Me.StatusBar1.Name = "StatusBar1"
        Me.StatusBar1.Panels.AddRange(New System.Windows.Forms.StatusBarPanel() {Me.StatusBarPanel1, Me.StatusBarPanel2, Me.StatusBarPanel3, Me.StatusBarPanel4})
        Me.StatusBar1.ShowPanels = True
        Me.StatusBar1.Size = New System.Drawing.Size(292, 22)
        Me.StatusBar1.TabIndex = 0
        Me.StatusBar1.Text = "StatusBar1"
        '
        'StatusBarPanel1
        '
        Me.StatusBarPanel1.Text = "StatusBarPanel1"
        '
        'StatusBarPanel2
        '
        Me.StatusBarPanel2.Text = "StatusBarPanel2"
        '
        'StatusBarPanel3
        '
        Me.StatusBarPanel3.Text = "StatusBarPanel3"
        '
        'StatusBarPanel4
        '
        Me.StatusBarPanel4.Text = "StatusBarPanel4"
        '
        'Form2
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(292, 266)
        Me.Controls.Add(Me.StatusBar1)
        Me.Name = "Form2"
        Me.Text = "Form2"
        CType(Me.StatusBarPanel1, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.StatusBarPanel2, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.StatusBarPanel3, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.StatusBarPanel4, System.ComponentModel.ISupportInitialize).EndInit()
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.StatusBarPanel2.Text = "somenew text"
    End Sub
End Class
0
 

Author Comment

by:Johnny
ID: 12406600
i give nothings working


0
 
LVL 18

Accepted Solution

by:
armoghan earned 2000 total points
ID: 12407061
I have visual Studio 2003.
I created a Form, added scrollbar on it. In scrollbar properties.. I added panels. added what ever text is required in those panels
I made the property ShowPanels = True,

Now i can see the panels and string in them in Designer as well

I double clicked the form to get the Form_Load method. as I do have the panels, so I added the following lines

Me.StatusBarPanel2.Text = "somenew text"

This is simple and straight forward.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question