|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
|
Announcements
Want a new Job?
Chapters
Services
Feature Zones
|
IntroductionThis article is about a This About ToolBox ControlClasses: +-------------+
| ToolObject |
+------o------+
|\________
| \
+------o------+ \
| ToolBoxItem | \
+------o------+ \
| \
| +----------------+
+------o------+ |ToolScrollButton|
| ToolBoxTab | +----------------+
+-------------+
+-------------+
| UserControl | // System.Windows.Forms.UserControl
+-------------+
|
|
+------o------+
| ToolBox |
+-------------+
The
These events are un-registered when the tab is removed. When the tab is disabled, the events except
Each Items are scrolled when a click occurs in a scroll button or at a mouse wheel event. If you want to set the Properties of interest.
Using the codeCreating the ToolBox:// In your panel or form, add the following code:
using Silver.UI; // At the top, you know ;)
ToolBox _toolBox = new ToolBox();
_toolBox.BackColor = System.Drawing.SystemColors.Control;
_toolBox.Dock = System.Windows.Forms.DockStyle.Fill;
_toolBox.TabHeight = 18;
_toolBox.ItemHeight = 20;
_toolBox.ItemSpacing = 1;
_toolBox.ItemHoverColor = System.Drawing.Color.BurlyWood;
_toolBox.ItemNormalColor = System.Drawing.SystemColors.Control;
_toolBox.ItemSelectedColor = System.Drawing.Color.Linen;
_toolBox.Name = "_toolBox";
_toolBox.Size = new System.Drawing.Size(208, 405);
_toolBox.Location = new System.Drawing.Point(0, 0);
Controls.Add(_toolBox);
Adding a Tab// Create the tab. (second parameter is the image index)
ToolBoxTab tab = new ToolBoxTab("Tab Name",1);
// Add the tab
_toolBox.AddTab(tab);
// Or add this way
_toolBox.AddTab("Another Tab ",-1);
Adding a Tab itemint tabIndex = 2;
_toolBox[tabIndex].AddItem("Item Caption", 10,
true, new Rectangle(10,10,100,100));
//Or this way
ToolBoxItem item = new ToolBoxItem();
item.Caption = "New Item";
item.Enabled = true;
item.ImageIndex = 12;
item.Object = new Rectangle(10,10,100,100);
_toolBox[tabIndex].AddItem(item);
Accessing TabsToolBoxTab tab;
//Selected Tab
tab = _toolBox.SelectedTab;
//Any tab
tab = _toolBox[tabIndex];
Accessing TabItemsTooBoxItem item;
//Selected item.
item = _toolBox.SelectedTab.SelectedItem;
//Any Item
item = _toolBox[tabIndex][itemIndex];
Events//Notification when a renaming of a tabitem is finished.
_toolBox.RenameFinished +=
new RenameFinishedHandler(ToolBox_RenameFinished);
private void ToolBox_RenameFinished(ToolBoxItem sender,
RenameFinishedEventArgs e)
{
// Set e.Cancel to true if rename was not acceptable.
e.Cancel = true;
}
// Tab Selection change notification
_toolBox.TabSelectionChanged += new
TabSelectionChangedHandler(ToolBox_TabSelectionChanged);
private void ToolBox_TabSelectionChanged(ToolBoxTab sender, EventArgs e)
{
//Add your code
}
// TabItem Selection change notification
_toolBox.ItemSelectionChanged += new
ItemSelectionChangedHandler(ToolBox_ItemSelectionChanged);
private void ToolBox_ItemSelectionChanged(ToolBoxItem sender,
EventArgs e)
{
//Add your code
}
//Mapping other events. (Item/Tab mouseup event can be used
//to show a context menu at the point of click)
_toolBox.TabMouseDown += new TabMouseEventHandler(ToolBox_TabMouseDown);
_toolBox.TabMouseUp += new TabMouseEventHandler(ToolBox_TabMouseUp);
_toolBox.ItemMouseDown += new ItemMouseEventHandler(ToolBox_ItemMouseDown);
_toolBox.ItemMouseUp += new ItemMouseEventHandler(ToolBox_ItemMouseUp);
Note: Update: 10/10/2005 - Added Points of Interest
Another really interesting thing is that I have not tested this control keenly. There might be bugs and bunnies. (Pssst! It is better to wrap the toolbox into a container like a Why the namespace Silver.UI?My name is Aju.George. So it's AG or Ag, chemically Ag means Silver. ;) So it's Me.UI :P Changes
Notes
|
||||||||||||||||||||||