Link to home
Start Free TrialLog in
Avatar of Moti Mashiah
Moti MashiahFlag for Canada

asked on

C# checkbox code

Hi Carl ,

I hope you still here :)....after the db guy created the new database and tables he added more columns and requested to add them to the app soo i did add these columns to the app and now it look like this see screenshot...

my missed understanding for now is how to add the checkbox to the column closed which provide database as "false or true" I want the checkbox to show me "v" inside the box and instead it shows me the word true or fales.

I have written the code for this checkbox this way:

string scheck = Reader.GetBoolean(Reader.GetOrdinal("closed")).ToString();

Open in new window

checkbox1.Text = scheck;

Open in new window

Capture.JPG
Avatar of Shaun Kline
Shaun Kline
Flag of United States of America image

Instead of setting the text property, set the checked property.
Avatar of Moti Mashiah

ASKER

that way I will see the "V" always in to the box.

My intention is to see the "V" in the checkbox when the database say true.
ASKER CERTIFIED SOLUTION
Avatar of Jerry Miller
Jerry Miller
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
thanks ,

After I changed I got this issue "cannot implicitly convert type string to bool
Declare scheck as a Boolean instead of a string.

bool scheck = Reader.GetBoolean(Reader.GetOrdinal("closed"))
Thank you very much now it works fine..

I have one more question:

I would like to query just the false from the "Close" Column. I assume I need some if statement for this.

can you help with the code.
solved my problem
If NOT checkbox1.Checked then
'do your processing
End if