Good Evening,
The WinForm project I am working on basically edits XML's easily without having to go through the code.
The problem I am having currently is when I load the XML with values I know are true. It does not tick the DataGridViewCheckBox, even though it is checked as true.
I've done a bit of research (well quite alot trying alot of different things) with no luck.
Below is the Method that Created a Column when a User is added and checks it depending if it is true of not...However it isn't physically checking the box.
private void AddColumnsUsersToSourceAllocation()
{
gridSourceToUser.SuspendLayout();
UpdateGrid(gridSources);
foreach (FCMUser user in fCMUserBindingSource.List)
{
string userName = user.name;
List<string> headerNamesList = new List<string>();
for (int i = 1; i < gridSourceToUser.ColumnCount; i++)
{
headerNamesList.Add(gridSourceToUser.Columns[i].HeaderText);
}
if (!headerNamesList.Any(x => x.Contains(userName)))
{
userCheckBoxColumn = new DataGridViewCheckBoxColumn()
{
HeaderText = userName,
FalseValue = 0,
TrueValue = 1,
Visible = true,
Name = userName,
};
gridSourceToUser.Columns.Add(userCheckBoxColumn);
}
foreach (var userSource in user.fusionUserSources)
{
if (userSource.UserSourceChkBox.MyCheckedState == true)
{
DataGridViewCheckBoxCell dgvCheckBox = gridSourceToUser.Rows[sourceProps.GetSourceIndex(userSource.id)].Cells[user.name] as DataGridViewCheckBoxCell;
if (dgvCheckBox == null) throw new ArgumentNullException(nameof(dgvCheckBox));
dgvCheckBox.Selected = true;
dgvCheckBox.Value = true;
}
}
UpdateGrid(gridSourceToUser);
}
gridSourceToUser.ResumeLayout();
}
Any help what so ever would be apprenticed, I'll try anything at this point :p
EDIT I have tried giving the added DataGridViewCheckBoxColumn a DataPropertyName which is a bool. This does work for loading the XML, however when editing clicking a Checkbox, clicks all the Checkboxes and sets them as true :s.
If you know a way around this feel free to say :)
Aucun commentaire:
Enregistrer un commentaire