Introducing Busy Indicator in Windows Forms | Syncfusion Blogs
Live Chat Icon For mobile
Live Chat Icon
Popular Categories.NET  (172).NET Core  (29).NET MAUI  (192)Angular  (107)ASP.NET  (51)ASP.NET Core  (82)ASP.NET MVC  (89)Azure  (40)Black Friday Deal  (1)Blazor  (209)BoldSign  (12)DocIO  (24)Essential JS 2  (106)Essential Studio  (200)File Formats  (63)Flutter  (131)JavaScript  (219)Microsoft  (118)PDF  (80)Python  (1)React  (98)Streamlit  (1)Succinctly series  (131)Syncfusion  (882)TypeScript  (33)Uno Platform  (3)UWP  (4)Vue  (45)Webinar  (49)Windows Forms  (61)WinUI  (68)WPF  (157)Xamarin  (161)XlsIO  (35)Other CategoriesBarcode  (5)BI  (29)Bold BI  (8)Bold Reports  (2)Build conference  (8)Business intelligence  (55)Button  (4)C#  (146)Chart  (125)Cloud  (15)Company  (443)Dashboard  (8)Data Science  (3)Data Validation  (8)DataGrid  (62)Development  (613)Doc  (7)DockingManager  (1)eBook  (99)Enterprise  (22)Entity Framework  (5)Essential Tools  (14)Excel  (37)Extensions  (22)File Manager  (6)Gantt  (18)Gauge  (12)Git  (5)Grid  (31)HTML  (13)Installer  (2)Knockout  (2)Language  (1)LINQPad  (1)Linux  (2)M-Commerce  (1)Metro Studio  (11)Mobile  (488)Mobile MVC  (9)OLAP server  (1)Open source  (1)Orubase  (12)Partners  (21)PDF viewer  (41)Performance  (12)PHP  (2)PivotGrid  (4)Predictive Analytics  (6)Report Server  (3)Reporting  (10)Reporting / Back Office  (11)Rich Text Editor  (12)Road Map  (12)Scheduler  (52)Security  (3)SfDataGrid  (9)Silverlight  (21)Sneak Peek  (31)Solution Services  (4)Spreadsheet  (11)SQL  (10)Stock Chart  (1)Surface  (4)Tablets  (5)Theme  (12)Tips and Tricks  (112)UI  (368)Uncategorized  (68)Unix  (2)User interface  (68)Visual State Manager  (2)Visual Studio  (30)Visual Studio Code  (17)Web  (577)What's new  (313)Windows 8  (19)Windows App  (2)Windows Phone  (15)Windows Phone 7  (9)WinRT  (26)

Introducing Busy Indicator in Windows Forms

We are excited to introduce the busy indicator drawing helper for Windows Forms. This busy indicator drawing helper has been implemented in our 2018 Volume 2 release. Usually, an animated GIF image cannot be shown in a Windows Forms control without using the picture box control or writing our own custom control. The busy indicator drawing helper helps you show animated GIF images in a control. The main advantage of this helper is that you can use it in any Windows Forms control, regardless of whether it is a Syncfusion control.

This blog explores how you can show animated GIF images using the busy indicator drawing helper in Windows Forms controls.

Getting started

Busy indicator is available in Syncfusion.Core.WinForms assembly. Refer to the control dependencies section to learn how to add an assembly reference to your application. BusyIndicator class provides the option to show an animated GIF image in the control. The Show method can be used to show the GIF image. By default, busy indicator shows the built-in GIF image. You can change the GIF image using the Image property or Show method.
Let’s see an example for showing the busy indicator in the button control. I’m going to show the busy indicator when a button is clicked, before an iteration gets started, and then hide it once the iteration gets completed.

 

public partial class Form1 : Form
{
    BusyIndicator busyIndicator = new BusyIndicator();
    ObservableCollection<int> sampleData = new ObservableCollection<int>();
    public Form1()
    {
        InitializeComponent();           
    }
    
    private void sfButton1_Click(object sender, EventArgs e)
    {
        this.sfButton1.Text = string.Empty;
        busyIndicator.Show(this.sfButton1);
        for (int i = 0; i <= 10000000; i++)
        {
            sampleData.Add(i);
        }
        busyIndicator.Hide();
        this.sfButton1.Text = "Get items";
        sampleData.Clear();
    }
}   

Showing busy indicator in a different location

By default, the GIF image will be shown at the center of the control. It’s easy to move the busy indicator to any location in the control, though. This can be done using the Location property or Show method.
public partial class Form1 : Form
{
    BusyIndicator busyIndicator = new BusyIndicator();
    ObservableCollection<int> sampleData = new ObservableCollection<int>();
    public Form1()
    {
        InitializeComponent();           
    }
    
    private void sfButton1_Click(object sender, EventArgs e)
    {
        this.sfButton1.Text = "Loading";
        busyIndicator.Show(this.sfButton1, new Point((this.sfButton1.Width / 2) + this.busyIndicator.Image.Width, (this.sfButton1.Height / 2) - this.busyIndicator.Image.Height / 2));
        for (int i = 0; i <= 10000000; i++)
        {
            sampleData.Add(i);
        }
        busyIndicator.Hide();
        this.sfButton1.Text = "Get items";
        sampleData.Clear();
    }
}

 

The sample can be downloaded from here.

Showing busy indicator in asynchronous mode

Busy indicator can be shown asynchronously in a control by handling the BackgroundWorker. The busy indicator can be shown when BackgroundWorker’s DoWork starts and can be hidden when BackgroundWorker’s RunWorkerCompleted is completed.
BackgroundWorker backgroundWorker = new BackgroundWorker();
BusyIndicator busyIndicator = new BusyIndicator();
ObservableCollection<int> sampleData = new ObservableCollection<int>();
public Form1()
{   
    InitializeComponent();           
    backgroundWorker.WorkerSupportsCancellation = true;
    backgroundWorker.DoWork += DoWork;
    backgroundWorker.RunWorkerCompleted += RunWorkerCompleted;
}

private void DoWork(object sender, DoWorkEventArgs e)
{
    this.sfButton1.Invoke(new Action(() => this.sfButton1.Text = string.Empty));
    busyIndicator.Show(this.sfButton1);
    for (int i = 0; i <= 10000000; i++)
    {
        sampleData.Add(i);
    }            
}

private void RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
    this.sfButton1.Text = "Get items";
    if (!backgroundWorker.IsBusy)
        backgroundWorker.CancelAsync();
    busyIndicator.Hide();
    sampleData.Clear();
}

private void sfButton1_Click(object sender, EventArgs e)
{
    backgroundWorker.RunWorkerAsync();
}
The sample can be downloaded from here.

Built-in busy indicator in data grid

Our new data grid has built-in busy indicator support for large data operations such as data loading, grouping, sorting, and filtering. Refer to this documentation to learn more about this support.

Summary

In this blog, we hope you enjoyed learning how to show the busy indicator in a Windows Forms control. You can also refer to this documentation to learn about additional options provided in the busy indicator. If you’re already a Syncfusion user, you can download the Windows Forms setup on Direct-Trac. If you’re not yet a Syncfusion user, you can download a free, 30-day trial on our website. Give us your feedback in the comments section below, our online forum, or a support ticket.

If you like this blog post, we think you’ll also like the following free e-books:

Tags:

Share this post:

Popular Now

Be the first to get updates

Subscribe RSS feed

Be the first to get updates

Subscribe RSS feed
Scroll To Top