Troubleshooting the DataRepeater Control (Visual Studio)

Updated: July 2008

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

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.

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;

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)

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.




July 2008

Added topic.

SP1 feature change.

Community Additions