次の方法で共有


DataGrid.FlatMode プロパティ

グリッドをフラット モードで表示するかどうかを示す値を取得または設定します。

Public Property FlatMode As Boolean
[C#]
public bool FlatMode {get; set;}
[C++]
public: __property bool get_FlatMode();public: __property void set_FlatMode(bool);
[JScript]
public function get FlatMode() : Boolean;public function set FlatMode(Boolean);

プロパティ値

グリッドをフラットに表示する場合は true 。それ以外の場合は false 。既定値は false です。

使用例

[Visual Basic, C#, C++] 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

[C#] 
// 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;
}

[C++] 
private:
    // Attach to event handler.
    void AttachFlatModeChanged() {
        this->myDataGrid->FlatModeChanged += 
            new EventHandler(this, &MyDataGridClass_FlatMode_ReadOnly::myDataGrid_FlatModeChanged);
    }

    // Check if the 'FlatMode' property is changed.
    void myDataGrid_FlatModeChanged(Object* /*sender*/, 
        EventArgs* /*e*/) {
            String* strMessage = S"false";
            if (myDataGrid->FlatMode == true)
                strMessage = S"true";

            MessageBox::Show(String::Concat(S"Flat mode changed to ", 
                strMessage), S"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;
    }

[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ

参照

DataGrid クラス | DataGrid メンバ | System.Windows.Forms 名前空間