DataGridViewCellBorderStyleとは? わかりやすく解説

DataGridView.CellBorderStyle プロパティ

メモ : このプロパティは、.NET Framework version 2.0新しく追加されたものです。

DataGridView のセル境界線スタイル取得します

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

Public Property CellBorderStyle As
 DataGridViewCellBorderStyle
Dim instance As DataGridView
Dim value As DataGridViewCellBorderStyle

value = instance.CellBorderStyle

instance.CellBorderStyle = value
public DataGridViewCellBorderStyle CellBorderStyle { get;
 set; }
public:
property DataGridViewCellBorderStyle CellBorderStyle {
    DataGridViewCellBorderStyle get ();
    void set (DataGridViewCellBorderStyle value);
}
/** @property */
public DataGridViewCellBorderStyle get_CellBorderStyle ()

/** @property */
public void set_CellBorderStyle (DataGridViewCellBorderStyle
 value)
public function get CellBorderStyle
 () : DataGridViewCellBorderStyle

public function set CellBorderStyle
 (value : DataGridViewCellBorderStyle)

プロパティ
DataGridView含まれるセル境界線スタイルを表す DataGridViewCellBorderStyle。

例外例外
例外種類条件

InvalidEnumArgumentException

このプロパティ設定時に指定された値が、有効な DataGridViewCellBorderStyle 値ではありません。

ArgumentException

このプロパティ設定時に指定された値は Custom です。

解説解説

CellBorderStyle プロパティSingle、SingleHorizontal、または SingleVertical 以外に設定されている場合、GridColor プロパティシステム カラーになる必要があります

このプロパティCustom 値に設定することはできません。この値は、AdvancedCellBorderStyle プロパティ使用によってセル境界線スタイルカスタマイズされたことを示す読み取り専用値です。

使用例使用例

CellBorderStyle プロパティ使用する方法次のコード例示します。この例を実行するには、dataGridView1 という名前の DataGridView配置されているフォームコード貼り付けフォームコンストラクタまたは Load イベント ハンドラから SetUpDataGridView メソッド呼び出します。必ずすべてのイベントイベント ハンドラ関連付けるようにしてください

Private Sub SetUpDataGridView()

    Me.Controls.Add(dataGridView1)
    dataGridView1.ColumnCount = 5

    With dataGridView1.ColumnHeadersDefaultCellStyle
        .BackColor = Color.Navy
        .ForeColor = Color.White
        .Font = New Font(dataGridView1.Font, FontStyle.Bold)
    End With

    With dataGridView1
        .EditMode = DataGridViewEditMode.EditOnEnter
        .Name = "dataGridView1"
        .Location = New Point(8, 8)
        .Size = New Size(500, 300)
        .AutoSizeRowsMode = _
            DataGridViewAutoSizeRowsMode.DisplayedCellsExceptHeaders
        .ColumnHeadersBorderStyle = _
            DataGridViewHeaderBorderStyle.Raised
        .CellBorderStyle = _
            DataGridViewCellBorderStyle.Single
        .GridColor = SystemColors.ActiveBorder
        .RowHeadersVisible = False

        .Columns(0).Name = "Release Date"
        .Columns(1).Name = "Track"
        .Columns(1).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
        .Columns(2).Name = "Title"
        .Columns(3).Name = "Artist"
        .Columns(4).Name = "Album"

        ' Make the font italic for row four.
        .Columns(4).DefaultCellStyle.Font = _
            New Font(Control.DefaultFont, _
                FontStyle.Italic)

        .SelectionMode = _
            DataGridViewSelectionMode.FullRowSelect
        .MultiSelect = False

        .BackgroundColor = Color.Honeydew

        .Dock = DockStyle.Fill
    End With

End Sub
private void SetUpDataGridView()
{
    this.Controls.Add(dataGridView1);
    dataGridView1.ColumnCount = 5;
    DataGridViewCellStyle style = 
        dataGridView1.ColumnHeadersDefaultCellStyle;
    style.BackColor = Color.Navy;
    style.ForeColor = Color.White;
    style.Font = new Font(dataGridView1.Font, FontStyle.Bold);

    dataGridView1.EditMode = DataGridViewEditMode.EditOnEnter;
    dataGridView1.Name = "dataGridView1";
    dataGridView1.Location = new Point(8, 8);
    dataGridView1.Size = new Size(500, 300);
    dataGridView1.AutoSizeRowsMode = 
        DataGridViewAutoSizeRowsMode.DisplayedCellsExceptHeaders;
    dataGridView1.ColumnHeadersBorderStyle = 
        DataGridViewHeaderBorderStyle.Raised;
    dataGridView1.CellBorderStyle = DataGridViewCellBorderStyle.Single;
    dataGridView1.GridColor = SystemColors.ActiveBorder;
    dataGridView1.RowHeadersVisible = false;

    dataGridView1.Columns[0].Name = "Release Date";
    dataGridView1.Columns[1].Name = "Track";
    dataGridView1.Columns[1].DefaultCellStyle.Alignment = 
        DataGridViewContentAlignment.MiddleCenter;
    dataGridView1.Columns[2].Name = "Title";
    dataGridView1.Columns[3].Name = "Artist";
    dataGridView1.Columns[4].Name = "Album";

    // Make the font italic for row four.
    dataGridView1.Columns[4].DefaultCellStyle.Font = new Font(DataGridView.DefaultFont,
 FontStyle.Italic);

    dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
    dataGridView1.MultiSelect = false;

    dataGridView1.BackgroundColor = Color.Honeydew;

    dataGridView1.Dock = DockStyle.Fill;

    dataGridView1.CellFormatting += new DataGridViewCellFormattingEventHandler(dataGridView1_CellFormatting);
    dataGridView1.CellParsing += new DataGridViewCellParsingEventHandler(dataGridView1_CellParsing);
    addNewRowButton.Click += new EventHandler(addNewRowButton_Click);
    deleteRowButton.Click += new EventHandler(deleteRowButton_Click);
    ledgerStyleButton.Click += new EventHandler(ledgerStyleButton_Click);
    dataGridView1.CellValidating += new DataGridViewCellValidatingEventHandler(dataGridView1_CellValidating);

}
void SetUpDataGridView()
{
   this->Controls->Add( dataGridView1 );
   dataGridView1->ColumnCount = 5;
   DataGridViewCellStyle^ style = dataGridView1->ColumnHeadersDefaultCellStyle;
   style->BackColor = Color::Navy;
   style->ForeColor = Color::White;
   style->Font = gcnew System::Drawing::Font( dataGridView1->Font,FontStyle::Bold
 );
   dataGridView1->EditMode = DataGridViewEditMode::EditOnEnter;
   dataGridView1->Name = "dataGridView1";
   dataGridView1->Location = Point(8,8);
   dataGridView1->Size = System::Drawing::Size( 500, 300 );
   dataGridView1->AutoSizeRowsMode = DataGridViewAutoSizeRowsMode::DisplayedCellsExceptHeaders;
   dataGridView1->ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle::Raised;
   dataGridView1->CellBorderStyle = DataGridViewCellBorderStyle::Single;
   dataGridView1->GridColor = SystemColors::ActiveBorder;
   dataGridView1->RowHeadersVisible = false;
   dataGridView1->Columns[ 0 ]->Name = "Release Date";
   dataGridView1->Columns[ 1 ]->Name = "Track";
   dataGridView1->Columns[ 1 ]->DefaultCellStyle->Alignment = DataGridViewContentAlignment::MiddleCenter;
   dataGridView1->Columns[ 2 ]->Name = "Title";
   dataGridView1->Columns[ 3 ]->Name = "Artist";
   dataGridView1->Columns[ 4 ]->Name = "Album";

   // Make the font italic for row four.
   dataGridView1->Columns[ 4 ]->DefaultCellStyle->Font = gcnew System::Drawing::Font(
 DataGridView::DefaultFont,FontStyle::Italic );
   dataGridView1->SelectionMode = DataGridViewSelectionMode::FullRowSelect;
   dataGridView1->MultiSelect = false;
   dataGridView1->BackgroundColor = Color::Honeydew;
   dataGridView1->Dock = DockStyle::Fill;
   dataGridView1->CellFormatting += gcnew DataGridViewCellFormattingEventHandler(
 this, &Form1::dataGridView1_CellFormatting );
   dataGridView1->CellParsing += gcnew DataGridViewCellParsingEventHandler( this,
 &Form1::dataGridView1_CellParsing );
   addNewRowButton->Click += gcnew EventHandler( this, &Form1::addNewRowButton_Click
 );
   deleteRowButton->Click += gcnew EventHandler( this, &Form1::deleteRowButton_Click
 );
   ledgerStyleButton->Click += gcnew EventHandler( this, &Form1::ledgerStyleButton_Click
 );
   dataGridView1->CellValidating += gcnew DataGridViewCellValidatingEventHandler(
 this, &Form1::dataGridView1_CellValidating );
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

DataGridViewCellBorderStyle 列挙体

メモ : この列挙体は、.NET Framework version 2.0新しく追加されたものです。

DataGridView コントロールセル適用できる境界線スタイル指定します

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

Public Enumeration DataGridViewCellBorderStyle
Dim instance As DataGridViewCellBorderStyle
public enum DataGridViewCellBorderStyle
public enum class DataGridViewCellBorderStyle
public enum DataGridViewCellBorderStyle
public enum DataGridViewCellBorderStyle
メンバメンバ
 メンバ説明
Customカスタマイズされた境界線。 
None境界線なし。 
Raised3D浮き出し境界線。 
RaisedHorizontal3D浮き出し平方向の境界線。 
RaisedVertical3D浮き出した垂直方向の境界線。 
Single一重線の境界線。  
SingleHorizontal平方向の一重線の境界線。 
SingleVertical直方向の一重線の境界線。 
Sunken3Dくぼんだ境界線。 
SunkenHorizontal3Dくぼんだ平方向の境界線。 
SunkenVertical3Dくぼんだ直方向の境界線。 
解説解説

DataGridView コントロールの CellBorderStyle プロパティは、DataGridViewCellBorderStyle 列挙体を使用します。行の間にのみ境界線描画するには、SingleHorizontal、SunkenHorizontal、または RaisedHorizontal を指定します。列の間にのみ境界線描画するには、SingleVertical、SunkenVertical、または RaisedVertical を指定します。行の間と列の間に境界線描画するには、SingleSunken、または Raised指定します

使用例使用例

この型の使用方法次のコード例示します

Private Sub SetBorderAndGridlineStyles()

    With Me.dataGridView1
        .GridColor = Color.BlueViolet
        .BorderStyle = BorderStyle.Fixed3D
        .CellBorderStyle = DataGridViewCellBorderStyle.None
        .RowHeadersBorderStyle = _
            DataGridViewHeaderBorderStyle.Single
        .ColumnHeadersBorderStyle = _
            DataGridViewHeaderBorderStyle.Single
    End With

End Sub
private void SetBorderAndGridlineStyles()
{
    this.dataGridView1.GridColor = Color.BlueViolet;
    this.dataGridView1.BorderStyle = BorderStyle.Fixed3D;
    this.dataGridView1.CellBorderStyle =
        DataGridViewCellBorderStyle.None;
    this.dataGridView1.RowHeadersBorderStyle =
        DataGridViewHeaderBorderStyle.Single;
    this.dataGridView1.ColumnHeadersBorderStyle =
        DataGridViewHeaderBorderStyle.Single;
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「DataGridViewCellBorderStyle」の関連用語

DataGridViewCellBorderStyleのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



DataGridViewCellBorderStyleのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS