You are not logged in.
This forum has been archived and no longer accepts new user registrations. Please report your questions, problems, and feedback to the issue page of ReoGrid on GitHub. Thank you for your cooperation.
Pages: 1
Topic closed
Jin,
I am creating checkboxes on my "Column A" when I read myy records to populate the worksheet
....
idx++;
aux = idx.ToString();
str = "A" + aux;
sheet[str] = new object[] { new CheckBoxCell(),""};
On the form closing event I'm trying to determine which checkbox (if any) was selected, and I'm doing
this according to the documentation in the Built-in Cell types
bool checkd;
for (int i = 0; i < sheet.MaxContentRow; i++)
{
str = "A" + i.ToString();
checkd = sheet[str] as bool;
...
}
VS is complaining that: "The as operator must be used with a reference type or nullable type ('bool' is a non-nullable value type)". Bool is indeed a non-nullable value type, so how to we check
if a checkbox is checked? sheet[str] is a type object, how do I make it a bool, cast?
Paul
Offline
Wrong example code in document, it has been corrected. Thanks!
bool isChecked = (sheet[str] as bool?) ?? false;
Jing
Offline
No thanks are needed, thank you for the tool.
Offline
Sorry Jing,
I can only get to my project as time permits.
Finally I got to continue and I think there is a typo on your suggestion
bool isChecked = (sheet[str] as bool?) ?? false;
This will force isChecked to always be false. I think the statement should read
bool isChecked = (sheet[str] as bool?) ?? true | false;
Paul
Offline
Hi Paul, no typo there, ?? is null-coalescing operator.
bool? a = true;
MessageBox.Show(((a as bool?) ?? false).ToString());
Result: True
Offline
Pages: 1
Topic closed