DataGridView の行や列に区切りを入れる

DataGridView の行や列に区切りを入れるときは、

を設定する。

using System;
using System.Windows.Forms;

namespace DataGridViewDividerWidthSample
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            for (Int32 columnIndex = 0; columnIndex < 3; ++columnIndex)
            {
                String name = String.Format("カラム {0}", columnIndex + 1);
                dataGridView1.Columns.Add(name, name);
            }

            for (Int32 rowIndex = 0; rowIndex < 3; ++rowIndex)
            {
                dataGridView1.Rows.Add();
            }

            dataGridView1.Columns[1].DividerWidth = 2;
            dataGridView1.Rows[1].DividerHeight = 2;
        }
    }
}

f:id:tt195361:20150618105236p:plain