DataGrid.FlatMode 属性

获取或设置一个值,该值指示网格是否以平面模式显示。

**命名空间:**System.Windows.Forms
**程序集:**System.Windows.Forms(在 system.windows.forms.dll 中)

语法

声明
Public Property FlatMode As Boolean
用法
Dim instance As DataGrid
Dim value As Boolean

value = instance.FlatMode

instance.FlatMode = value
public bool FlatMode { get; set; }
public:
property bool FlatMode {
    bool get ();
    void set (bool value);
}
/** @property */
public boolean get_FlatMode ()

/** @property */
public void set_FlatMode (boolean value)
public function get FlatMode () : boolean

public function set FlatMode (value : boolean)

属性值

如果网格以平面显示,则为 true;否则为 false。默认为 false

示例

下面的代码示例检查 FlatMode 属性并将其状态通知用户。

' Check if the 'FlatMode' property is changed.
Private Sub myDataGrid_FlatModeChanged(ByVal sender As Object, ByVal e As EventArgs) Handles myDataGrid.FlatModeChanged
    Dim strMessage As String = "false"
    If myDataGrid.FlatMode = True Then
        strMessage = "true"
    End If
    MessageBox.Show("Flat mode changed to " + strMessage, "Message", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End Sub 'myDataGrid_FlatModeChanged


' Toggle the 'FlatMode'.
Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles button1.Click
    If myDataGrid.FlatMode = True Then
        myDataGrid.FlatMode = False
    Else
        myDataGrid.FlatMode = True
    End If
End Sub 'button1_Click
// 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;
}
   // Attach to event handler.
private:
   void AttachFlatModeChanged()
   {
      this->myDataGrid->FlatModeChanged +=
            gcnew EventHandler( this, &MyDataGridClass_FlatMode_ReadOnly::myDataGrid_FlatModeChanged );
   }

   // Check if the 'FlatMode' property is changed.
   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'.
   void button1_Click( Object^ /*sender*/, EventArgs^ /*e*/ )
   {
      if ( myDataGrid->FlatMode == true )
            myDataGrid->FlatMode = false;
      else
            myDataGrid->FlatMode = true;
   }
// Attach to event handler.
private void AttachFlatModeChanged()
{
    this.myDataGrid.add_FlatModeChanged(new EventHandler(
        this.myDataGrid_FlatModeChanged));
} //AttachFlatModeChanged

// Check if the 'FlatMode' property is changed.
private void myDataGrid_FlatModeChanged(Object sender, EventArgs e)
{
    String strMessage = "false";
    if (myDataGrid.get_FlatMode() == true) {
        strMessage = "true";
    }
    MessageBox.Show("Flat mode changed to " + strMessage, "Message",
        MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
} //myDataGrid_FlatModeChanged

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

平台

Windows 98、Windows 2000 SP4、Windows CE、Windows Millennium Edition、Windows Mobile for Pocket PC、Windows Mobile for Smartphone、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

请参见

参考

DataGrid 类
DataGrid 成员
System.Windows.Forms 命名空间