I am trying to add a DataGridViewCheckBoxColumn with three states, and for some reason, all the checkboxes are in intermediate state - even if they should be in true or false state:
DataGridViewCheckBoxColumn with three states
My code is:
List<PointTable> listOffsetSitesForDataGridView = dicOffsetSites.Values.ToList();
DataGridViewOffsets.DataSource = listOffsetSitesForDataGridView;
DataGridViewCheckBoxColumn chk = new DataGridViewCheckBoxColumn();
DataGridViewOffsets.Columns.Add(chk);
chk.ThreeState = true;
chk.HeaderText = "Exists";
chk.Name = "chk";
chk.ValueType = typeof(OffsetSitesState);
chk.TrueValue = OffsetSitesState.eAll;
chk.FalseValue = OffsetSitesState.eNone;
chk.IndeterminateValue = OffsetSitesState.ePartial;
int iPointNumber = -1;
for (int iRowNumber = 0; iRowNumber < DataGridViewOffsets.Rows.Count; iRowNumber++ )
{
bool bConverted = int.TryParse(DataGridViewOffsets.Rows[iRowNumber].Cells["PointNumber"].Value.ToString(), out iPointNumber);
if (bConverted == true)
{
if (iMaxCount == dicOffsetSitesCounter[iPointNumber])
{
DataGridViewOffsets.Rows[iRowNumber].Cells["chk"].Value = OffsetSitesState.eAll;
}
else if (dicOffsetSitesCounter[iPointNumber] == 0)
{
DataGridViewOffsets.Rows[iRowNumber].Cells["chk"].Value = OffsetSitesState.eNone;
}
else
{
DataGridViewOffsets.Rows[iRowNumber].Cells["chk"].Value = OffsetSitesState.ePartial;
}
}
}
Thanks for your help, Reut.
Aucun commentaire:
Enregistrer un commentaire