0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

(WinForms)セル・行・列・DataGridView のいずれかが ReadOnly=true ならセルは読み取り専用になる

Posted at

はじめに

タイトルが全てです。この仕様を知らなくてしばらく悩んでいたので忘れないように残しておきます。

特定の列のみReadOnly=falseにする方法

DataGridView全体をReadOnly=trueとして、特定の列のみReadOnly=falseにしたいとする。
このときの失敗例と成功例を示す。

失敗例

全体=true → 特定列=false
DataGridView全体をReadOnly=trueに設定し、その後特定の列でReadOnly=falseに書き換えようとしてもうまく動作しません。これはタイトルにある通り「セル・行・列・DataGridView のいずれかが ReadOnly=true ならセルは読み取り専用になる」から。

成功例

全体=false,特定列=false,個別に他の列を=true
これで個別の設定が効く。

おわりに

全体や列への設定が各セルへの一括設定のようなイメージでしたが、別物なんですね。
記事にしたので、もう忘れない。はず。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?