Version

Retrieving Selected Elements

Topic Overview

Purpose

This topic describes the events and their arguments used to retrieve information about the currently selected cells, columns or rows in the xamGantt™ control.

Required background

The following topics are prerequisites to understanding this topic:

Topic Purpose

This topic describes how to add the xamGantt control to a page.

In this topic

This topic contains the following sections:

Events Summary

Events summary chart

The following table lists the events for retrieving the selected elements in the xamGantt control.

In order to: Handle this event: The event argument exposes the following information:

Identify the selected xamGantt cells

Identify the selected xamGantt columns

Identify the selected xamGantt rows

Code Example: Identifying the Selected Tasks

Description

The code snippet demonstrates how to use xamGantt SelectedRowsChanged event to identify the currently selected tasks and their names.

Multiple rows can be selected; however, selecting a xamGantt row triggers the SelectedRowsChanged event.

Code

In XAML:

<ig:XamGantt x:Name="gantt"
             Project="{Binding Project}"
             SelectedRowsChanged="gantt_SelectedRowsChanged"/>

In C#:

private void gantt_SelectedRowsChanged(object sender, GanttGridSelectionChangedEventArgs<GanttGridRow> e)
{
    // Get the newly selected rows
    var selectedRows = e.NewSelectedItems;
    foreach (GanttGridRow row in selectedRows)
    {
        string msg = string.Format("The {0} task is selected.", row.Task.TaskName);
        System.Diagnostics.Debug.WriteLine(msg);
    }
    System.Diagnostics.Debug.WriteLine("Selected rows count is " + selectedRows.Count);
}

In Visual Basic:

Private Sub gantt_SelectedRowsChanged(sender As Object, e As GanttGridSelectionChangedEventArgs(Of GanttGridRow))
    ' Get the newly selected rows
    Dim selectedRows = e.NewSelectedItems
    For Each row As GanttGridRow In selectedRows
        Dim msg As String = String.Format("The {0} task is selected.", row.Task.TaskName)
        System.Diagnostics.Debug.WriteLine(msg)
    Next
    System.Diagnostics.Debug.WriteLine("Selected rows count is " & Convert.ToString(selectedRows.Count))
End Sub

Related Topics

The following topics provide additional information related to this topic.

Topic Purpose

This topic describes the properties and events used to set or retrieve the currently active cell, column or row in the xamGantt control.

This topic describes some of the available events triggered by common user interactions in the xamGantt control.