Solved

C# checkbox code

Posted on 2014-04-08
8
325 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 26

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 500 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
 
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

762 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now