473,322 Members | 1,620 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

CheckBox quesion. Work on something other than boolean?

Just wondering if a checkbox field is designed to work on anything other
than a boolean type field. If not fine, I just need to know. I have many
fields in a SQL Server 2000 table that are Var fields with a width of 1.
These fields contain a Y or an N or a Null. Looks like I may need to
convert these fields to Bit fields if I want them to work with Checkboxes in
VS.net.

Is this correct?

Nov 20 '05 #1
3 1642
Hi Woody,

A Checkbox's Checked property can not be bound to anything other than a
Boolean field of a data source. This is to ensure .net's type-safe feature.

If you want to bind its value to other types, you have to write a Subclass
of Checkbox. Here's an example. The CheckStr property can be bound to a
String field.

Public Class clsCheckBox
Inherits CheckBox
Public Property CheckedStr()
Get
If Checked Then
Return "Y"
Else
Return "N"
End If
End Get
Set(ByVal Value)
If Value.ToString() = "Y" Then
Checked = True
Else
Checked = False
End If
End Set
End Property
End Class

If anything is unclear, please feel free to reply to the post.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 20 '05 #2
Hi Woody,

I don't know what you mean by "checkbox field", but the WinForms CheckBox
requires a value from the enum CheckState, ie. CheckState.Checked,
CheckState.Indeterminate or CheckState.Unchecked - it won't even accept True!
(but it will allow False as this matches Unchecked).

In answer to your earlier RadioButton question, and perhaps to what you
want with your CheckBoxes, I suggest that you have hidden Controls that you
<know> will accept your data, eg a TextBox. These Controls can then handle
their change event and set their "partner" Control accordingly.

Hope this helps - I can see your frustration :-).

Regards,
Fergus
Nov 20 '05 #3
Hi again,

Oops. I'm thinking of CheckState (3-state checkboxes). For Boolean,
there's plain old Checked, of course.

Regards,
Fergus
Nov 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Michael Champagne | last post by:
We have an application to where you can select/deselect all checkboxes in a checkbox array by clicking a 'master' checkbox at the top of the screen. This seems to work fine unless there is only...
2
by: Sebi | last post by:
Hello all is it possible to add a checkbox in a DataGrid for Boolean Data? Thanks in advance
0
by: mike | last post by:
Hi there: I've read an excellent "how to"-article by Microsoft (no. 306227) - partly cited cited at the end of this email). I have implemented the code related to the part "How to Add a...
5
by: Dave | last post by:
Hi all, I'm new to ASP.NET and am working through a few exercises in a book to get up to speed. First, some background: I'm running SQL Server 2000 and have one field as a bit data type...
1
by: dx | last post by:
I'm extremely frustrated with ASP.NET...again! To me this should be as simple as setting oCheckBox.Checked = True.. yet for some reason it isn't. I have a user control (ascx) that that has a...
6
by: Bill Nguyen | last post by:
I need to add a checkbox in front of all the rows in a datagrid so that users can select/unselect them. Any help is greatly appreciated! Bill
4
by: Hexman | last post by:
Hello All, I'd like to find out the best way to add a cb column to a dgv and process efficiently. I see at least two ways of doing it. ------------------------------- 1) Add a cb to the dgv,...
2
by: =?Utf-8?B?UmljaA==?= | last post by:
Is there a cancel argument for cancelling if you want to check or uncheck a checkbox? In the checkChanged event of a checkbox I ask the user if they are sure they want to check/uncheck...
2
by: mrstrong | last post by:
Gday, I have a datagridview that I am creating the columns programatically which all seems to work fine. I have a couple of dropdown boxes, so I have set the editMode= EditOnEnter. Now my...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.