Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


C# checkbox code

Posted on 2014-04-08
Medium Priority
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

Question by:Moti Mashiah
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
LVL 27

Expert Comment

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

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.
LVL 18

Accepted Solution

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;
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!


Author Comment

by:Moti Mashiah
ID: 39987246
thanks ,

After I changed I got this issue "cannot implicitly convert type string to bool
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"))

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.

Author Closing Comment

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

Expert Comment

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

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

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…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

721 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