0

ボタンイベントDataGridViewRowの後、全体を編集モードにしようとしています。clickプログラムでセルを編集する必要がある場合は、以下のコードを使用しますが、BeginEdit行では機能せず、1つのセルしか編集できません。

DataGridView.CurrentCell.ReadOnly = false;
DataGridView.BeginEdit(true);

全体をDataGridViewRow編集可能にするにはどうすればよいですか?

4

1 に答える 1

0

There is a standard way that the DataGridView is supposed to work ... try to make it work differently and you are in for much frustration and large quantities of code.

There are several things I can think of here:

1) Find a third-party grid control that does what you need.

2) Write your own grid control to do this.

3) Try to make the DataGridView do what it was not designed to do.

I am assuming by your message that you are restricted to option 3? If so, then you could try this:

  • Keep a flag denoting that you are in edit mode (I hate flag-based programming - but sometimes there is no other easy choice...).

  • When the user clicks the button, set the flag and execute BeginEdit on the cell.

  • On the EndEdit, use BeginEdit to start edit of the next cell (assuming the flag is still set).

  • When the user presses the Enter key, exit edit on the currenlty edited cell and turn the flag off (which should prevent any other cell from being edited).

于 2012-09-24T11:54:52.953 に答える