Performing an StatusBar

Aug 29, 2010 at 8:36 PM

This is an idea easy to implement. In the CustomScrollControl.cs file we can define a StatusBar in the same way the HScrollBar is, to be added to the panelDockBottom. And after, resize it to be shown next to HScrollBar at the bottom of de Grid.

We need to add the next code to CustomScrollControl.cs file:

        private StatusBar mStatusBar = new StatusBar();
        /// <summary>
        /// Gets the Status bar. Can be visible or unvisible.
        /// </summary>
        [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public StatusBar StatusBar
        {
            get { return mStatusBar; }
        }

 In the CreateDockControls() function we add:

       panelDockBottom.Controls.Add(mStatusBar);
       panelDockBottom.Resize += new EventHandler(panelDockBottom_Resize);
       mStatusBar.Dock = DockStyle.None

We need to set mStatusBar.Dock = DockStyle.None to let us calculate and set the location and size.

In the Example 4 of the solution where appear:

        this.toolStripStatusLabelBuildTime.Text = string.Format(
        "Rows added in {0} ms", counter.GetMilisec());

we replace it for:

        grid.StatusBar.Text = string.Format(
        "Rows added in {0} ms", counter.GetMilisec());

We need to remove the toolStrip control from the Form, and provide the code to resize HScroll and StatusBar properly (i.e. StatusBar 65%width and HScrollBar 35% width). We can add an EventHandler to intercept panelDockBottom resize and calculate size and position for StatusBar and HScrollBar.

That's all.