Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 29th, 2012  |  syntax: None  |  size: 1.08 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. C#: DataGridViewCheckBoxCell strange behaviour
  2. foreach (string pre in preselect)
  3. {
  4.     foreach (DataGridViewRow row in dgvProtFunc.Rows)
  5.     {
  6.         if ((string)row.Cells[2].Value == pre)
  7.         {
  8.             ((DataGridViewCheckBoxCell)row.Cells[0]).Value = true;
  9.         }
  10.     }
  11. }
  12.        
  13. private void dgvProtFunc_CurrentCellDirtyStateChanged(object sender, EventArgs e)
  14. {
  15.     if (dgvProtFunc.IsCurrentCellDirty)
  16.     {
  17.         dgvProtFunc.CommitEdit(DataGridViewDataErrorContexts.Commit);
  18.     }
  19. }
  20.  
  21. private void dgvProtFunc_CellValueChanged(object sender, DataGridViewCellEventArgs e)
  22. {
  23.     if (!FormLoadCheck)
  24.     {
  25.         string data = string.Empty;
  26.         ptSelectList.Clear();
  27.         foreach (DataGridViewRow row in dgvProtFunc.Rows)
  28.         {
  29.            if (row.Cells[0].Value != null && Convert.ToBoolean(row.Cells[0].Value) == true)
  30.            {
  31.                ptSelectList.Add(Convert.ToInt32(row.Cells[1].Value));
  32.            }
  33.            data += row.Cells[0].Value;
  34.         }
  35.         ptSelectList.Sort();
  36.         FilterRelais(ptSelectList.ToArray());
  37.         MessageBox.Show(data);
  38.    }
  39. }