Solved

C# checkbox code

Posted on 2014-04-08
8
331 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
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

Technology Partners: 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!

Question has a verified solution.

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

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
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!
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

710 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