Control.AddRange(…) is slow

Posting this answer because the OP requested it: This is how you’d do something like that in WPF: <UserControl x:Class=”WpfApplication7.ListBoxSample” xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation” xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml”> <DockPanel> <Button Content=”Load” Click=”Load_Click” DockPanel.Dock=”Top”/> <ListBox ItemsSource=”{Binding}” HorizontalContentAlignment=”Stretch”> <ListBox.ItemTemplate> <DataTemplate> <Border BorderBrush=”LightGray” BorderThickness=”1″ Padding=”5″ Background=”#FFFAFAFA”> <Grid> <Grid.RowDefinitions> <RowDefinition Height=”Auto”/> <RowDefinition Height=”Auto”/> <RowDefinition Height=”Auto”/> <RowDefinition/> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition/> <ColumnDefinition/> <ColumnDefinition/> <ColumnDefinition/> </Grid.ColumnDefinitions> <TextBlock Text=”Dependent … Read more

Center multiple rows of controls in a FlowLayoutPanel

Here’s an example that reproduces the behaviour you described. It makes use of a TableLayoutPanel which hosts multiple FlowLayoutPanels. One important detail is the anchoring of the child FlowLayoutPanels: they need to be anchored to Top-Bottom: this causes the panel to be positioned in the center of a TableLayoutPanel Row. Note that, in the Form … Read more