# Step 4 of 5: Adding Code to the Project

## Content

In the last step, you added four items to the **C1CoverFlow** control and set the items’ properties. In this step, you’re going to create a **C1CoverFlow.SelectedIndexChanged** event handler and add code to the event handler that checks for the value of the **C1CoverFlow.SelectedIndex** property. The **TextBlock** control, which you added in [Step 1 of 5: Creating the Project](/componentone/docs/wpf/online-extended/CoverFlow2/CoverFlowSLQS/CFStep1of5), will change its **Text** property string value when the user selects an album cover.

Complete the following steps:

1. In the **Objects and Timeline** panel, select **C1CoverFlow1**.
2. In the Properties panel, click the **Events** button .
3. Locate the **C1CoverFlow.SelectedIndexChanged** event handler and double-click inside its text box.

The **C1CoverFlow1\_SelectedIndexChanged** event handler is added to your project.

Replace the code comment with the following code:

```vbnet
If C1CoverFlow1.SelectedIndex = 1 Then
   TextBlock1.Text = "Deep Purple: Machine Head"
ElseIf C1CoverFlow1.SelectedIndex = 2 Then
   TextBlock1.Text = "Deep Purple: Made in Japan"
ElseIf C1CoverFlow1.SelectedIndex = 3 Then
   TextBlock1.Text = "Deep Purple: Perfect Strangers"
Else
TextBlock1.Text = Nothing
End If
```

```csharp
if (C1CoverFlow1.SelectedIndex == 1)
{
TextBlock1.Text = "Deep Purple: Machine Head";
}
else if (C1CoverFlow1.SelectedIndex == 2)
{
TextBlock1.Text = "Deep Purple: Made in Japan";
}
else if (C1CoverFlow1.SelectedIndex == 3)
{
TextBlock1.Text = "Deep Purple: Perfect Strangers";
}
else
{
   TextBlock1.Text = null;
}
```

In this step, you added an event handler and code to your project. In the next step, you’ll run program and see the results of this quick start topic.