Troubleshooting the DataRepeater Control (Visual Studio)

This topic lists common issues that may occur when you are working with the DataRepeater control.

DataRepeater Keyboard and Mouse Events Are Not Raised

Some DataRepeater control events, such as keyboard and mouse events, are not raised. This is by design. The DataRepeater control itself is a container for DataRepeaterItem objects and cannot be accessed at run time. The DataRepeaterItem does not expose events at design time. Therefore, clicking an item or pressing a key when the item has focus does not raise an event.

The exception to this is when the Padding property is set to a large enough value to expose the edges of the DataRepeater control. In this case, clicking in the exposed margin will raise mouse events.

To resolve this issue, add a Panel control to the ItemTemplate section of the DataRepeater control, and then add the rest of the controls to the Panel. You can then add code to the Panel control's event handlers for keyboard and mouse events.

The DataRepeater Is Partially Hidden Behind the Binding Navigator

When you first add a DataRepeater control to a form and then add data-bound controls from the Data Sources window, the BindingNavigator control may appear on top of the DataRepeater control. This is a known limitation of the Data Sources window and is consistent with the behavior of other controls, such as the DataGridView control.

You can either move the DataRepeater lower than the BindingNavigator control at design time, or add code resembling the following in the Load event handler.

DataRepeater1.Top = ProductsBindingNavigator.Height  
dataRepeater1.Top = productsBindingNavigator.Height;  

Controls Are Not Displayed Correctly at Run Time

Some controls in a DataRepeater control may not be displayed as expected at run time. The process used to clone controls from the ItemTemplate to the DataRepeaterItem cannot always determine all the properties of all controls. For example, if you add an unbound ListBox control to a DataRepeater control at design time and populate its Items collection with a list of strings, the ListBox will be empty at run time. This is because the cloning process cannot take into account the Items property.

You can fix problems such as this by restoring the missing properties in the ItemCloned event, which occurs after the default cloning is completed. The following example demonstrates how to repair the Items collection of a ListBox control in the ItemCloned event handler.

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)
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
End Sub

The Selection Symbol on the Item Header Is Missing

When you change the SelectionColor property of the item header in a DataRepeater control, some color choices may cause the selection symbol to disappear. Changing the ItemHeaderSize property may also cause the selection symbol to disappear.

The color and size of the selection symbol cannot be changed.

  • If you set the SelectionColor to White, the selection symbol will not be visible when an item is first selected.

  • If you set the SelectionColor to Black, the selection symbol will not be visible when a control is selected, and the pencil symbol will not be visible when a control is in edit mode.

  • If the ItemHeaderSize property is set to a value that is less than 11, the indicator symbols in the item header will not be displayed.

You can provide your own item header and selection symbol by using a PictureBox control and monitoring the IsCurrent property of the DataRepeaterItem in the DrawItem event of the DataRepeater control. For more information, see IsCurrent.

See Also

Introduction to the DataRepeater Control
How to: Display Bound Data in a DataRepeater Control
How to: Display Unbound Controls in a DataRepeater Control
How to: Change the Layout of a DataRepeater Control
How to: Change the Appearance of a DataRepeater Control
How to: Display Item Headers in a DataRepeater Control
How to: Disable Adding and Deleting DataRepeater Items
How to: Search Data in a DataRepeater Control
How to: Create a Master/Detail Form by Using Two DataRepeater Controls (Visual Studio)