# Events

Once your board is configured you can use the events of the component to interact with the data.

| Event Name       | Description                                        |
| ---------------- | -------------------------------------------------- |
| WorkItemDragged  | Set when a Work Item card is dragged by a user     |
| AddWorkItem      | Set when a user selects a Boards Add new item icon |
| WorkItemSelected | Set when the user clicks on a Work Item Title      |

### OnChange property

This property will be triggered as any change happens on the kanban. The events presented above will be detected and you can define the outcome by using a switch statement:

```csharp
Switch(
    Self.EventType,
    "WorkItemDragged",
    Patch(
        WorkProgressTracker,
        LookUp(
            WorkProgressTracker,
            ID = Value(Self.CurrentWorkItemID)
        ),
        {
            Progress: Switch(
                Self.CurrentBoardID,
                "1",
                {Value: "Not started"},
                "2",
                {Value: "In progress"},
                "3",
                {Value: "Completed"},
                "4",
                {Value: "Blocked"}
            )
        }
    ),
    "WorkItemSelected",
    Set(
        _Record,
        LookUp(
            WorkProgressTracker,
            ID = Value(Self.CurrentWorkItemID)
        )
    );
    EditForm(FormTasks);
    Navigate(
        'New Task Screen test',
        Fade
    ),
    "AddWorkItem",
    NewForm(FormTasks);
    Navigate(
        'New Task Screen test',
        Fade
    );
    Set(
        _DefaultProgress,
        Switch(
            Self.CurrentBoardID,
            "1",
            {Value: "Not started"},
            "2",
            {Value: "In progress"},
            "3",
            {Value: "Completed"},
            "4",
            {Value: "Blocked"}
        )
    )
)
```

### Add new item using kanban board

Selecting the plus icon on any of the board sections will trigger the event "AddNewItem". As you can see in the formula we just create we are setting up a variable to store what is the progress.

![](https://3220951636-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnUfK4SRGZUB01uvHGeDB%2Fuploads%2FJGh2Zohew3615lBd7Fc1%2Fimage.png?alt=media\&token=c3f2b40d-00e1-4d66-9053-44a9278a93a3)

This will allow us to have the Progress selection of our form pre-filled. We just need to use the formula below on the datacard Default property:

```csharp
If(FormTasks.Mode = FormMode.Edit, ThisItem.Progress, _DefaultProgress)
```

![Control wll be filled based on the selected progress](https://3220951636-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnUfK4SRGZUB01uvHGeDB%2Fuploads%2FaNQm60FqUT36j2nje0hG%2Fimage.png?alt=media\&token=e3f4e0ae-42cc-4030-8bb4-e12d88e907c4)

### Editing item using Kanban board

As you click any of the cards, the event "WorkItemSelected" will be triggered. As this happens we are storing the record into the variable **\_Record** and turning the state of the form to edit mode. This will allow us to edit the record on the form.

On **item** property of the form place the variable:

```
_Record
```
