FlatMode Property

DataGrid.FlatMode Property

 

Gets or sets a value indicating whether the grid displays in flat mode.

Namespace:   System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

public bool FlatMode { get; set; }

Property Value

Type: System.Boolean

true if the grid is displayed flat; otherwise, false. The default is false.

The following code example examines the FlatMode property and notifies the user of its status.

// Attach to event handler.
private void AttachFlatModeChanged()
{
   this.myDataGrid.FlatModeChanged += new EventHandler(this.myDataGrid_FlatModeChanged);
}
// Check if the 'FlatMode' property is changed.
private void myDataGrid_FlatModeChanged(object sender, EventArgs e)
{
   string strMessage = "false";
   if(myDataGrid.FlatMode == true)
      strMessage = "true";

   MessageBox.Show("Flat mode changed to "+strMessage,
      "Message",   MessageBoxButtons.OK,
      MessageBoxIcon.Exclamation);

}
// Toggle the 'FlatMode'.
private void button1_Click(object sender, EventArgs e)
{
   if(myDataGrid.FlatMode == true)
      myDataGrid.FlatMode = false;
   else
      myDataGrid.FlatMode = true;
}

.NET Framework
Available since 1.1
Return to top
Show:
© 2016 Microsoft