DataRepeater.ItemCloned Event

Occurs after the DataRepeaterItem and its controls are cloned from the ItemTemplate.

Namespace:  Microsoft.VisualBasic.PowerPacks
Assembly:  Microsoft.VisualBasic.PowerPacks.Vs (in Microsoft.VisualBasic.PowerPacks.Vs.dll)

Syntax

'Declaração
Public Event ItemCloned As DataRepeaterItemEventHandler
public event DataRepeaterItemEventHandler ItemCloned
public:
 event DataRepeaterItemEventHandler^ ItemCloned {
    void add (DataRepeaterItemEventHandler^ value);
    void remove (DataRepeaterItemEventHandler^ value);
}
member ItemCloned : IEvent<DataRepeaterItemEventHandler,
    DataRepeaterItemEventArgs>
JScript does not support events.

Remarks

Use this event to fix the display of any controls that are not cloned correctly by the default cloning process. For example, a ListBox control might not be populated with data during cloning; you can populate the list in the ItemCloned event handler.

Observação

If you need complete control over the cloning process, use the ItemCloning event instead.

For more information about how to handle events, see Consuming Events.

Examples

The following example demonstrates how to repair the Items collection of a ListBox control in the ItemCloned event handler.

Private Sub DataRepeater1_ItemCloned(
    ByVal sender As Object, 
    ByVal e As Microsoft.VisualBasic.PowerPacks.DataRepeaterItemEventArgs
  ) Handles DataRepeater1.ItemCloned

    Dim Source As ListBox = 
        CType(DataRepeater1.ItemTemplate.Controls.Item("ListBox1"), ListBox)
    Dim ListBox1 As ListBox = 
        CType(e.DataRepeaterItem.Controls.Item("ListBox1"), ListBox)
    For Each s As String In Source.Items
        ListBox1.Items.Add(s)
    Next
End Sub
private void dataRepeater1_ItemCloned(object sender, 
    Microsoft.VisualBasic.PowerPacks.DataRepeaterItemEventArgs e)
{
    ListBox Source = (ListBox)dataRepeater1.ItemTemplate.Controls["listBox1"];
    ListBox listBox1 = (ListBox)e.DataRepeaterItem.Controls["listBox1"];
    foreach (string s in Source.Items)
    {
        listBox1.Items.Add(s);
    }
}

.NET Framework Security

See Also

Reference

DataRepeater Class

Microsoft.VisualBasic.PowerPacks Namespace

ItemCloning

Other Resources

Introduction to the DataRepeater Control (Visual Studio)