I wanted to throw my thoughts out to the list on creating a reusable
toolbar (Win Forms).  Normally a toolbar is constructed within the form
at runtime and is a one off job.

Now when I say reusable, I mean the buttons and bitmaps are already
defined with some base functionality.  For example, a toolbar that has
some drawing tools like Paint.  The idea would be that the control could
live in the VS Forms Toolbox and be added to forms as desired like any
other control.

I see a number of possible options:
1. Create a new user control, mimicking the functionality of a toolbar.
Pros are it does exactly what I want.  Cons are that you have to write
all of the code from scratch (essentially).

2. Inherit from System.Windows.Forms.ToolBar.  This seems the most
obvious but I'm having trouble wrapping my brain around this one,
normally you instantiate a Toolbar on your form along with a bunch of
ToolBarButtons and then add them to it...etc.  Now if I want this to be
a self contained control then this doesn't really work.

3. Aggregate the Toolbar and ToolBarButtons as members of my own class
inheriting from UserControl (or something).  This way I have a parent
like a form that constructs the final toolbar.  The problem I see here
is how would I hook into the various toolbar events and messages?

As you can tell, I am trying to get a better understanding of how this
should all work and any feedback is definitely appreciated.

Thanks,

Kollen

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to