1

行から特定のセルを合計しようとすると問題が発生します。値を入力してから別の行をクリックすると、時間がかかりすぎます。同じ行の別のセルをクリックしても、これは起こりません。

これはCellValidatedイベントでの私のコードです。

if (!_comparare)
{
    if (dataGridView1.Columns[e.ColumnIndex].HeaderText.Contains("COM"))
    {
        int total = 0;
        foreach (Gestiune gest in _selectedGestiuni)
        {
            int n = 0;
            total += Convert.ToInt32(int.TryParse(dataGridView1["COM_" + gest.Den_Gest, e.RowIndex].Value.ToString(), out n) ? dataGridView1["COM_" + gest.Den_Gest, e.RowIndex].Value : 0);
        }
        dataGridView1["Total", e.RowIndex].Value = total;
    }
}

私を助けてください。同じ行のセルを通過するときほど速く動作しない理由がわかりません。

4

1 に答える 1

0

からコードを変更してみてください

dataGridView1["COM_" + gest.Den_Gest, e.RowIndex].Value.ToString()


dataGridView1["COM_" + gest.Den_Gest, e.RowIndex].EditedValue.ToString()
于 2012-12-02T13:54:03.667 に答える