开发者

Global Status Bar

I have a status bar the I made initialize when the form loads. The problem is I need to know how to make it global so that I can update it as I m开发者_JAVA百科ove on to other areas of my app. Any Ideas?

EDIT: Nevermind I figured it out by doing this then coding it in the Form1_Load. Now I can change the status bar text by statusPanel.Text = blablabal later on.

public partial class Form1 : Form
{
    StatusBar mainStatusBar = new StatusBar();
    StatusBarPanel statusPanel = new StatusBarPanel();
    StatusBarPanel datetimePanel = new StatusBarPanel();
    public Form1()


Maybe you can create a class for that status bar,

public static class StatusBar
{
   public void Start()
   {
      //Code for your status bar
   }
}

Then you can invoke StatusBar.Start() on your Form_Load events.

Hope this helps.


One way to achieve this is to create a "shell" form for your application, which contains global UI objects like status bars, common buttons, etc. Within the shell you define an area (e.g. a Panel) where you will show your application content. The concept is similar to master pages in ASP.NET if you're familiar with that.

If you define your application content items as UserControls or some type of control that you can render within the Shell's content panel, then your shell can act as the conductor for the overall application. The application content controls can hook into the shell to modify the global items like status bars, etc.

This type of pattern is sometimes called "Screen Activator" or "Screen Conductor." You can implement it in a lot of different ways depending on how complex you want to get.


Expose the status bar as a public property and then you should be able to access it from other classes.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜