Skip to main content

LayoutGroup.Accept(BaseVisitor) Method

Invokes the Visit method of the specified visitor for each layout item that belongs to the current layout item group.

Namespace: DevExpress.XtraLayout

Assembly: DevExpress.XtraLayout.v23.2.dll

NuGet Package: DevExpress.Win.Navigation

Declaration

public override void Accept(
    BaseVisitor visitor
)

Parameters

Name Type Description
visitor DevExpress.XtraLayout.Utils.BaseVisitor

A DevExpress.XtraLayout.Utils.BaseVisitor class descendant.

Remarks

The Accept method lets you recursively iterate through the layout items that belong to the current layout item group and perform a specific operation on the items.

To iterate through the items of a specific layout item group do the following:

  • Create a DevExpress.XtraLayout.Utils.BaseVisitor class descendant;
  • Override its Visit method to implement an operation to be performed on layout items;
  • Call the group’s Accept method with an instance of the created class as a parameter.

The Visit method will be invoked for the current group first and then recursively for each child item within the group.

Example

The following code shows how to iterate through the items that belong to a specific layout item group. To iterate through the items the LayoutGroup.Accept method is used.

This method takes a descendant of the DevExpress.XtraLayout.Utils.BaseVisitor class as a parameter. When this method is called it iterates through the items that belong to the current layout item group and invokes the visitor’s Visit method for each layout item.

In the example, the Visit method of the MyVisitor class sets the BaseLayoutItem.TextVisible property to true for layout items.

// A custom visitor class.
class MyVisitor : DevExpress.XtraLayout.Utils.BaseVisitor {
   // This method will be invoked for each layout item in a group.
   public override void Visit(DevExpress.XtraLayout.BaseLayoutItem item) {
      if(item is DevExpress.XtraLayout.LayoutControlItem) {
         item.TextVisible = true;
      }
   }
}

// Get a layout group whose items should be iterated through.
DevExpress.XtraLayout.LayoutControlGroup group = layoutControl1.Root;
// Iterate through the items.
group.Accept(new MyVisitor());
See Also