Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

C# checkbox code

Posted on 2014-04-08
8
Medium Priority
?
337 Views
Last Modified: 2014-04-08
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
Comment
Question by:Moti Mashiah
  • 4
  • 3
8 Comments
 
LVL 27

Expert Comment

by:Shaun Kline
ID: 39987151
Instead of setting the text property, set the checked property.
0
 
LVL 1

Author Comment

by:Moti Mashiah
ID: 39987175
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
 
LVL 18

Accepted Solution

by:
Jerry Miller earned 2000 total points
ID: 39987228
Like Shaun stated, you need to set the checked and not the text.

checkbox1.Checked= scheck; instead of checkbox1.Text = scheck;
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:Moti Mashiah
ID: 39987246
thanks ,

After I changed I got this issue "cannot implicitly convert type string to bool
0
 
LVL 18

Expert Comment

by:Jerry Miller
ID: 39987252
Declare scheck as a Boolean instead of a string.

bool scheck = Reader.GetBoolean(Reader.GetOrdinal("closed"))
0
 
LVL 1

Author Comment

by:Moti Mashiah
ID: 39987265
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
 
LVL 1

Author Closing Comment

by:Moti Mashiah
ID: 39987331
solved my problem
0
 
LVL 18

Expert Comment

by:Jerry Miller
ID: 39987578
If NOT checkbox1.Checked then
'do your processing
End if
0

Featured Post

[Webinar] Cloud Security

In this webinar you will learn:

-Why existing firewall and DMZ architectures are not suited for securing cloud applications
-How to make your enterprise “Cloud Ready”, and fix your aging DMZ architecture
-How to transform your enterprise and become a Cloud Enabler

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question