This is a migrated thread and some comments may be shown as answers.

Problem Adding RadProgressBarElement to Status Strip

2 Answers 137 Views
StatusStrip
This is a migrated thread and some comments may be shown as answers.
Patrick Baggett
Top achievements
Rank 2
Patrick Baggett asked on 20 Apr 2011, 05:58 PM
I'm having problems adding a RadProgressBarElement real-time to a RadStatusStrip. When I add the progressbar to the statusstrip, it does not show.

code:
radStatusStrip1.Items.Clear(); 
radProgressBarElement1.Text = "Extracting Rollback Contents"
radProgressBarElement1.Maximum = 100; 
radProgressBarElement1.Minimum = 0; 
radProgressBarElement1.AutoSizeMode = RadAutoSizeMode.FitToAvailableSize; 
radProgressBarElement1.Visibility = ElementVisibility.Visible; 
radProgressBarElement1.Enabled = true
radStatusStrip1.Items.Add(radProgressBarElement1); 
radStatusStrip1.Update(); 
radStatusStrip1.Refresh(); 
    
// loops here and increments progress status 
    
radStatusStrip1.Items.Clear(); 
RadLabelElement1.Text = "Showing Contents of " + myDate + " Rollback File"
radProgressBarElement1.Text = ""
radStatusStrip1.Items.Add(RadLabelElement1); 
radStatusStrip1.Update(); 
radStatusStrip1.Refresh();

After my loop, the RadLabelElement shows in the status strip as designed.  To add to my confusion, I can also add the progressbar at this point and it shows up as well??? 

Any idea what I'm doing wrong? 

 

2 Answers, 1 is accepted

Sort by
0
Richard Slade
Top achievements
Rank 2
answered on 21 Apr 2011, 11:42 AM
Hello Patrick,

Here is a small example for you. I find it best to run the progress on a background worker.

Form1 Designer
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class Form1
    Inherits System.Windows.Forms.Form
  
    'Form overrides dispose to clean up the component list.
    <System.Diagnostics.DebuggerNonUserCode()> _
    Protected Overrides Sub Dispose(ByVal disposing As Boolean)
        Try
            If disposing AndAlso components IsNot Nothing Then
                components.Dispose()
            End If
        Finally
            MyBase.Dispose(disposing)
        End Try
    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.
    <System.Diagnostics.DebuggerStepThrough()> _
    Private Sub InitializeComponent()
        Me.RadStatusStrip1 = New Telerik.WinControls.UI.RadStatusStrip()
        Me.RadButton1 = New Telerik.WinControls.UI.RadButton()
        CType(Me.RadStatusStrip1, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.RadButton1, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.SuspendLayout()
        '
        'RadStatusStrip1
        '
        Me.RadStatusStrip1.AutoSize = True
        Me.RadStatusStrip1.LayoutStyle = Telerik.WinControls.UI.RadStatusBarLayoutStyle.Stack
        Me.RadStatusStrip1.Location = New System.Drawing.Point(0, 53)
        Me.RadStatusStrip1.Name = "RadStatusStrip1"
        Me.RadStatusStrip1.Size = New System.Drawing.Size(284, 26)
        Me.RadStatusStrip1.TabIndex = 0
        Me.RadStatusStrip1.Text = "RadStatusStrip1"
        '
        'RadButton1
        '
        Me.RadButton1.Location = New System.Drawing.Point(99, 12)
        Me.RadButton1.Name = "RadButton1"
        Me.RadButton1.Size = New System.Drawing.Size(71, 24)
        Me.RadButton1.TabIndex = 1
        Me.RadButton1.Text = "Start"
        '
        'Form1
        '
        Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
        Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
        Me.ClientSize = New System.Drawing.Size(284, 79)
        Me.Controls.Add(Me.RadButton1)
        Me.Controls.Add(Me.RadStatusStrip1)
        Me.Name = "Form1"
        Me.Text = "Form1"
        CType(Me.RadStatusStrip1, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.RadButton1, System.ComponentModel.ISupportInitialize).EndInit()
        Me.ResumeLayout(False)
        Me.PerformLayout()
  
    End Sub
    Friend WithEvents RadStatusStrip1 As Telerik.WinControls.UI.RadStatusStrip
    Friend WithEvents RadButton1 As Telerik.WinControls.UI.RadButton
  
End Class

Form1.vb
Imports Telerik.WinControls.UI
Imports Telerik.WinControls
  
Public Class Form1
  
    Private m_ProgressBar As New RadProgressBarElement()
    Private m_Label As New RadLabelElement()
    Private WithEvents m_BackgroundWorker As New System.ComponentModel.BackgroundWorker()
  
    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        m_BackgroundWorker.WorkerReportsProgress = True
  
        m_Label.Text = "Ready"
        Me.RadStatusStrip1.Items.Add(m_Label)
  
        m_ProgressBar.MinSize = New System.Drawing.Size(200, 20)
        Me.RadStatusStrip1.Items.Add(m_ProgressBar)
  
        ResetProgressBar(False)
    End Sub
  
    Private Sub RadButton1_Click(sender As System.Object, e As System.EventArgs) Handles RadButton1.Click
        m_Label.Visibility = ElementVisibility.Collapsed
        ResetProgressBar(True)
        m_BackgroundWorker.RunWorkerAsync()
    End Sub
  
    Private Sub BackgroundWorker_RunWorker(sender As Object, e As System.ComponentModel.DoWorkEventArgs) Handles m_BackgroundWorker.DoWork
        For i As Integer = 0 To 100
            m_BackgroundWorker.ReportProgress(i)
            System.Threading.Thread.Sleep(50)
        Next i
    End Sub
  
    Private Sub BackgroundWorker_ProgressChanged(sender As Object, e As System.ComponentModel.ProgressChangedEventArgs) Handles m_BackgroundWorker.ProgressChanged
        m_ProgressBar.Value1 = e.ProgressPercentage
    End Sub
  
    Private Sub BackgroundWorker_Complete(sender As Object, e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles m_BackgroundWorker.RunWorkerCompleted
        m_Label.Visibility = ElementVisibility.Visible
        ResetProgressBar(False)
        If e.Error Is Nothing Then
            m_Label.Text = "Finished"
        Else
            m_Label.Text = e.Error.Message
        End If
    End Sub
  
    Private Sub ResetProgressBar(visible As Boolean)
        m_ProgressBar.Value1 = 0
        If visible Then
            m_ProgressBar.Visibility = ElementVisibility.Visible
        Else
            m_ProgressBar.Visibility = ElementVisibility.Collapsed
        End If
    End Sub
  
  
End Class

Hope that helps
Richard
0
Ivan Petrov
Telerik team
answered on 22 Apr 2011, 01:58 PM
Hello Patrick,

Thank you for writing.

Richard's solution is working fine on my machine. I implemented it and attached the solution for you to try. If you are still experiencing this issue, I would kindly ask you to prepare a sample project where you reproduce the issue and send it to us through a support ticket where you can attach files.

I hope this will help. If you need further assistance, I would be glad to provide it.

All the best,
Ivan Petrov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
StatusStrip
Asked by
Patrick Baggett
Top achievements
Rank 2
Answers by
Richard Slade
Top achievements
Rank 2
Ivan Petrov
Telerik team
Share this question
or