ICreate.Controls.Bars Send comments on this topic.
ItemCold Event
See Also  Example
ICreate.Controls.Bars Namespace > TaskBar Class : ItemCold Event






Occurs when the mouse cursor moves off a TaskBarItem owned by the TaskBar.

Syntax

Visual Basic (Declaration) 
Public Event ItemCold() As TaskBarItemEventHandler
Visual Basic (Usage)Copy Code
Dim instance As TaskBar
Dim handler As TaskBarItemEventHandler
 
AddHandler instance.ItemCold, handler
C# 
public event TaskBarItemEventHandler ItemCold()
Delphi 
public event ItemCold: TaskBarItemEventHandler; 
JScript 
In JScript, you can handle the events defined by another class, but you cannot define your own.
Managed Extensions for C++ 
public: __event TaskBarItemEventHandler* ItemCold();
C++/CLI 
public:
event TaskBarItemEventHandler^ ItemCold();

Event Data

The event handler receives an argument of type TaskBarItemEventArgs containing data related to this event. The following TaskBarItemEventArgs properties provide information specific to this event.

PropertyDescription
Item Gets the TaskBarItem associated with the event.

Example

This example shows how to attach to the ItemCold event. It also shows how to implement an ItemCold event handler.

This example has a TaskBar with four TaskBarItems: taskBarItemBuyStock; taskBarItemSellStock; taskBarItemBuyBonds; taskBarItemSellBonds. Each TaskBarItem has a string assigned to its Tag property. This string is displayed as the text of a Label control when the item is hot. The example also shows a MessageBox with an appropriate message when a TaskBarItem is clicked.

C#Copy Code
using System; 
using System.Windows.Forms; 
 
namespace ExamplesTaskBarCSharp 

    public partial class TaskBarEventsExample : Form 
    { 
        public TaskBarEventsExample() 
        { 
            InitializeComponent(); 
 
            taskBar.Items["taskBarItemBuyStocks"].Tag = "Purhase stocks for inclusion in the selected portfolio."; 
            taskBar.Items["taskBarItemSellStocks"].Tag = "Sell stocks for the currently selected portfolio."; 
            taskBar.Items["taskBarItemBuyBonds"].Tag = "Purhase bonds for inclusion in the selected portfolio."; 
            taskBar.Items["taskBarItemSellBonds"].Tag = "Sell bonds for the currently selected portfolio."; 
 
            taskBar.ItemHot += new ICreate.Controls.Bars.TaskBarItemEventHandler(taskBar_ItemHot); 
            taskBar.ItemCold += new ICreate.Controls.Bars.TaskBarItemEventHandler(taskBar_ItemCold); 
            taskBar.ItemSelected += new ICreate.Controls.Bars.TaskBarItemEventHandler(taskBar_ItemSelected); 
        } 
 
        private void taskBar_ItemHot(object sender, ICreate.Controls.Bars.TaskBarItemEventArgs args) 
        { 
            labelTip.Text = args.Item.Tag.ToString(); 
        } 
 
        private void taskBar_ItemCold(object sender, ICreate.Controls.Bars.TaskBarItemEventArgs args) 
        { 
            labelTip.Text = ""; 
        } 
 
        private void taskBar_ItemSelected(object sender, ICreate.Controls.Bars.TaskBarItemEventArgs args) 
        { 
            if (args.Item.Name == "taskBarItemBuyStocks") 
                ProcessBuyStocks(); 
            else if (args.Item.Name == "taskBarItemSellStocks") 
                ProcessSellStocks(); 
            else if (args.Item.Name == "taskBarItemBuyBonds") 
                ProcessBuyBonds(); 
            else if (args.Item.Name == "taskBarItemSellBonds") 
                ProcessSellBonds(); 
        } 
 
        private void ProcessBuyStocks() 
        { 
            MessageBox.Show("Process buy stock"); 
        } 
 
        private void ProcessSellStocks() 
        { 
            MessageBox.Show("Process sell stocks"); 
        } 
 
        private void ProcessBuyStock() 
        { 
            MessageBox.Show("Process buy stocks"); 
        } 
 
        private void ProcessBuyBonds() 
        { 
            MessageBox.Show("Process sell bonds"); 
        } 
 
        private void ProcessSellBonds() 
        { 
            MessageBox.Show("Process buy bonds"); 
        } 
    } 
}
Visual BasicCopy Code
Imports ICreate.Controls.Bars

Public Class TaskBarClassExample

    Public Sub New()

        InitializeComponent()

        taskBar = New TaskBar
        Dim alignLeft As TaskBarItem = New TaskBarItem("Left", Image.FromFile("Resources\left.png"))
        Dim alignCentre As TaskBarItem = New TaskBarItem("Centre", Image.FromFile("Resources\left.png"))
        Dim alignRight As TaskBarItem = New TaskBarItem("Right", Image.FromFile("Resources\right.png"))

        alignLeft.Name = "AlignLeft"
        alignCentre.Name = "AlignCentre"
        alignRight.Name = "AlignRight"

        taskBar.Text = "Image alignment"
        taskBar.TitleImage = Image.FromFile("Resources\alignment.png")
        taskBar.Watermark = Image.FromFile("Resources\alignment.png")
        taskBar.WatermarkBounds = New Rectangle(100, 10, 96, 96)
        taskBar.Animate = True

        AddHandler taskBar.ItemSelected, AddressOf OnItemSelected

        taskBar.Items.Add(alignLeft)
        taskBar.Items.Add(alignCentre)
        taskBar.Items.Add(alignRight)

        Me.Controls.Add(taskBar)

    End Sub

    Sub OnItemSelected(ByVal sender As Object, ByVal args As TaskBarItemEventArgs)

        If args.Item.Name = "AlignLeft" Then
            LeftAlignItems()
        Else
            If args.Item.Name = "AlignCentre" Then
                CentreAlignItems()
            Else
                If args.Item.Name = "AlignRight" Then
                    RightAlignItems()
                End If
            End If
        End If

    End Sub

    Private Sub LeftAlignItems()

        MessageBox.Show("Left align the selected items.")

    End Sub

    Private Sub CentreAlignItems()

        MessageBox.Show("Centre align the selected items.")

    End Sub

    Private Sub RightAlignItems()

        MessageBox.Show("Right align the selected items.")

    End Sub

    Private taskBar As TaskBar

End Class

Remarks

Note that the same results can be achieved by subscribing to the TaskBarItem Cold event

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also