Glossary Item Box
You can access cell values in the active Record through xamDataPresenter's™ RecordActivated event. For example, if you were making a data entry area on your Page/Window, you could use this event to populate the fields in your entry area based on the active Record selected by the end user.
The following procedure assumes you have a data bound xamDataPresenter and you want to handle the RecordActivated event for the control, to populate editors on the Page/Window based on the end users active Record. For more information, see Creating xamDataPresenter in XAML.
In XAML:
<igDP:XamDataPresenter x:Name="XamDataPresenter1"
...
RecordActivated="XamDataPresenter1_RecordActivated">
<igDP:XamDataPresenter.View>
<igDP:GridView/>
</igDP:XamDataPresenter.View>
</igDP:XamDataPresenter>
<Label x:Name="Label1" Content="Data Entry" Margin="0,5,0,0" FontSize="15.0"/>
<igEditors:XamTextEditor x:Name="ProductName" Margin="0,5,0,0"/>
<igEditors:XamNumericEditor x:Name="CostPerUnit" Margin="0,5,0,0"/>
<igEditors:XamNumericEditor x:Name="Quantity" Margin="0,5,0,0"/>
<igEditors:XamNumericEditor x:Name="Discount" Margin="0,5,0,0"/>
<igEditors:XamNumericEditor x:Name="ShipandHandle" Margin="0,5,0,0"/>
In Visual Basic:
Imports Infragistics.Windows.DataPresenter.Events
Imports Infragistics.Windows.DataPresenter
In C#:
using Infragistics.Windows.DataPresenter.Events;
using Infragistics.Windows.DataPresenter;
In Visual Basic:
Sub XamDataPresenter1_RecordActivated(ByVal sender As Object, _
ByVal e As RecordActivatedEventArgs)
' Check to make sure the selected Record is a DataRecord
If TypeOf e.Record Is DataRecord Then
' Cast the record passed in as a DataRecord
Dim myRecord As DataRecord = CType(e.Record, DataRecord)
' Display the selected Records values in the appropriate
' editor
Me.ProductName.Text = myRecord.Cells(0).Value.ToString()
Me.CostPerUnit.Value = myRecord.Cells(1).Value
Me.Quantity.Text = myRecord.Cells(2).Value.ToString()
Me.Discount.Text = myRecord.Cells(3).Value.ToString()
Me.ShipandHandle.Value = myRecord.Cells(4).Value
End If
End Sub
In C#:
void XamDataPresenter1_RecordActivated(object sender, RecordActivatedEventArgs e)
{
// Check to make sure the selected Record is a DataRecord
if (e.Record is DataRecord)
{
// Cast the record passed in as a DataRecord
DataRecord myRecord = (DataRecord)e.Record;
// Display the selected Records values in the appropriate
// editor
this.ProductName.Text = myRecord.Cells[0].Value.ToString();
this.CostPerUnit.Value = myRecord.Cells[1].Value;
this.Quantity.Text = myRecord.Cells[2].Value.ToString();
this.Discount.Text = myRecord.Cells[3].Value.ToString();
this.ShipandHandle.Value = myRecord.Cells[4].Value;
}
}
