|
■No55231 (DD. さん) に返信
> SelectionModeにRowHeaderSelectとColumnHeaderSelectを同時指定するような動作は可能なのでしょうか?
private void Form1_Load(object sender, EventArgs e)
{
dataGridView1.DataSource = null;
dataGridView1.AllowUserToAddRows = false;
dataGridView1.ColumnCount = 5;
dataGridView1.RowCount = 20;
dataGridView1.Dock = DockStyle.Fill;
dataGridView1.SelectionMode = DataGridViewSelectionMode.CellSelect;
dataGridView1.MultiSelect = true;
dataGridView1.Tag = null;
dataGridView1.SelectionChanged += delegate
{
if (dataGridView1.Tag == null)
{
dataGridView1.Tag = new object();
Point pt = dataGridView1.CurrentCellAddress;
dataGridView1.ClearSelection();
for (int c = 0; c < dataGridView1.ColumnCount; c++)
{
dataGridView1[c, pt.Y].Selected = true;
}
for (int r = 0; r < dataGridView1.RowCount; r++)
{
dataGridView1[pt.X, r].Selected = true;
}
dataGridView1.Tag = null;
}
};
}
|