Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 351
  • Last Modified:

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
0
Moti Mashiah
Asked:
Moti Mashiah
  • 4
  • 3
1 Solution
 
Shaun KlineLead Software EngineerCommented:
Instead of setting the text property, set the checked property.
0
 
Moti Mashiah.NET DeveloperAuthor Commented:
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.
0
 
Jerry MillerCommented:
Like Shaun stated, you need to set the checked and not the text.

checkbox1.Checked= scheck; instead of checkbox1.Text = scheck;
0
What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

 
Moti Mashiah.NET DeveloperAuthor Commented:
thanks ,

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

bool scheck = Reader.GetBoolean(Reader.GetOrdinal("closed"))
0
 
Moti Mashiah.NET DeveloperAuthor Commented:
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.
0
 
Moti Mashiah.NET DeveloperAuthor Commented:
solved my problem
0
 
Jerry MillerCommented:
If NOT checkbox1.Checked then
'do your processing
End if
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now