Skip to main content
A newer version of this page is available. .

GridControl.ForceInitialize() Method

Forces the grid control to finish its initialization. Call this method when the form is loading, before you start to change the grid’s options.

Namespace: DevExpress.XtraGrid

Assembly: DevExpress.XtraGrid.v19.1.dll

Declaration

public virtual void ForceInitialize()

Remarks

After the grid control has been initialized, you can manipulate its settings safely. Call the ForceInitialize method before you:

  • group and/or sort data;
  • change summary settings;
  • expand and collapse rows;
  • create columns and change their visibility;
  • restore a layout, etc.

Note

The ForceInitialize method has no effect until the form’s Load event occurs. For instance, nothing will happen if you add this method in the form’s constructor.

The code sample below illustrates how to safely add a column to a grid.


using DevExpress.XtraGrid;
using DevExpress.XtraGrid.Views.Grid;

private void XtraForm1_Load(object sender, EventArgs e)
{
    gridControl1.ForceInitialize();
    gridView1.Columns.Add();
    gridView1.Columns[gridView1.Columns.Count - 1].Caption = "Actions";
    gridView1.Columns[gridView1.Columns.Count - 1].VisibleIndex = gridView1.Columns.Count;
}

The following code snippets (auto-collected from DevExpress Examples) contain references to the ForceInitialize() method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also