)
We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to add or remove Layout groups and image streamer dynamically in WinForms TileLayout?

Platform: WinForms |
Control: TileLayout |
Published Date: February 19, 2016 |
Last Revised Date: February 4, 2020

Add or remove layout groups and image streamer

In Tile Layout, the Layout groups and ImageStreamer can be added or removed dynamically in TileLayout by following below steps.

Adding an ImageStreamer:

1. Need to add the LayoutGroup to TileGroupCollection by using the property named “Groups” in TileLayout.

2. Need to add required control to ControlCollection of the Layout Group.

Removing an ImageStreamer:

1. Need to iterate the Layout groups.

2. Need to iterate all the controls of the Layout group.

3. Remove the required control from the control collection.

C#

LayoutGroup layoutGroup1 = new LayoutGroup();
// To add the Layout group to TileLayout
this.tileLayout1.Groups.Add(layoutGroup1);
ImageStreamer img = new ImageStreamer();
img.BackColor = Color.Red;
// To add the ImageStreamer to Layout group.
this.layoutGroup1.Controls.Add(img);
 
//Remove the  controls.
foreach (LayoutGroup lObjGroup in this.tileLayout1.Groups)
{
    foreach (Control lObjControl in lObjGroup.Controls)
    {
        lObjGroup.Controls.Remove(lObjControl);
        lObjGroup.Items.Remove(lObjControl);
    }
}

VB

Dim layoutGroup1 As New LayoutGroup()
' To add the Layout group to TileLayout
Me.tileLayout1.Groups.Add(layoutGroup1)
Dim img As New ImageStreamer()
img.BackColor = Color.Red
' To add the ImageStreamer to Layout group.
Me.layoutGroup1.Controls.Add(img)
 
'Remove the  controls.
For Each lObjGroup As LayoutGroup In Me.tileLayout1.Groups
    For Each lObjControl As Control In lObjGroup.Controls
        lObjGroup.Controls.Remove(lObjControl)
        lObjGroup.Items.Remove(lObjControl)
    Next lObjControl
Next lObjGroup

 Layout group and Image streamer added dynamically

Figure 1. Layout group and Image streamer added dynamically.

Layout group and Image streamer removed dynamically

Figure 2. Layout group and Image streamer removed dynamically.

Samples:

C#: TileLayout_Groups_C#

VB: TileLayout_Groups_VB

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon