Thursday, March 01, 2001 ..:: Home ::.. Register  Login
   TechTidBits (Blog)  

Want to make your WinForms application look just a bit more professional? Check out this easy implementation of the StatusStrip!

Apr 12

Written by:
Sunday, April 12, 2009 12:59 PM  RssIcon

Want to make your WinForms application look just a bit more professional?  Read on for one quick'n'easy thing you can do to bran your newly created (or in maintenance) WinForm with your company logo!

Do you want to make your Windows application look juuuuuuuust that little bit more polished?  Just a bit more professional?  To separate yourself from the rest of the pack, but not cost you an arm'n'leg?  I have JUST the trick!  In less than the time it takes to walk over to the coffee machine and get a cup of liquid gold, you can add a small class touch to your WinForm!  This applies to WPF apps too, but the source code, pics and etc are all WinForms based (for now, I'll put a WPF app up later). 

Here is what the completed version of the CompanyLogoOnStatusBar looks like.  Notice the company logo on the bottom right hand side corner.  A couple of things to notice/mention are:

  • The image is in a ToolStripStatusLavel control, yup, the Label is being used to hold the image, fancy trick eh?
  • You still have resizing control over the form, notice the resizing handle in the extreme bottom right hand side?  Yup, that still works perfectly!
  • Along with resizing, the company image will always stay in the bottom right hand side, just what you want, AND you don't have to do anything to make that work, the StatusStrip does all the heavy lifting for you.  BEAUTY!
  • And lastly, the magic to make this work, isn't actually the image/company logo, no, it's the ToolStripStatusLabel juuuuust previous to the CompanyLogo, you'll see this in a sec.

Company Logo on StatusStrip at runtime

Let's back up, just a bit.  When you are looking at your form for the first time (or one hundredth time if you're in maintenance) , you're going to want to put a StatusStrip control onto your form.

StatusStrip Control in Toolbox

 When you place it onto the form, your form will look like this (look at the control at the bottom). 

StatusStrip On Form

Now that's done, you'll have to three other things, a company logo, setup two labels in the StatusStrip and a couple key properties and we're done.

Company Logo

When you get your company logo, try to get a version which will fit into the status bar, should be 20pixels high.  Why?  Cause if it's too big, it'll push the StatusStrip to match your logos height and if it's too high, it'll look weird.  You can try it out to see what you think.

Setup Two StatusStripLabels

You can of course have more, but at a minimum to get this to work, you'll need to setup at least two.  One for the company logo on the right hand side, and one for the status messages, but more importantly to set a property (Spring = True) which will always push the company logo picture to the far right hand side.  You can choose to put no text into that status label if you wish, but I figure if I have the option, I'll give the user some feedback.

Key Properties

As I just mentioned, this is where the magic happens.  This is the settings for the Company Logo with the imporant ones circled in red.  Notice how the image is coming from the resources?  The DisplayStyle = Image makes sure not to include the Text property in the display and the ImageScaling make sure not to grow/shrink the image inappropriately.

CompanyLogo Properties

Next is the properties for the lable just before the company logo.  Notice the Spring = true, this is what forces/pushes the company logo to the far right all the time as the form is resized, this is key to make this all work out.  Otherwise your company logo will always appear on the left hand side of the form tight up against your message text.  Maybe thats what you want, in that case, put back the default value.  Another important setting is to the TextAlign = MiddleLeft, this forces the text to the left hand side, otherwise the default is in the middle.  That could be ok for you too, it's your call.

Message Status Label

Another small use for the company logo is to provide your customer with a quick'n' easy link back to your company's corporate website or maybe to your forums or support environment.  The possibilities are endless! :>

At the end of all this, you'll have a spiffier form and a more professional looking application for your company.  Now go grab that coffee I was talking about and get coding! :>


Source Code:

Location: Blogs Parent Separator TechTidBits

Your name:
Gravatar Preview
Your email:
(Optional) Email used only to show Gravatar.
Your website:
Add Comment   Cancel 
Copyright 1999-2012 by   Terms Of Use  Privacy Statement