473,394 Members | 1,640 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,394 software developers and data experts.

DataGridBoolColumn?

I have a number of bool columns within a datagrid, but they dont work as
expected.

The underlying table is Access 2000. The datatype for the underlying fields
is Yes/No.

I am attempting to create DataGridBoolColumns using the following code:

Private Const TRUE_VAL = -1

Private Const FALSE_VAL = 0

Private Const NULL_VAL = 0

Me.dgdTimDatPlotChkForks = New DataGridBoolColumn()

Me.dgdTimDatPlotChkForks.HeaderText = "FORKS"

Me.dgdTimDatPlotChkForks.MappingName = "FORKS"

Me.dgdTimDatPlotChkForks.Width = 75

Me.dgdTimDatPlotChkForks.AllowNull = False

Me.dgdTimDatPlotChkForks.TrueValue = TRUE_VAL

Me.dgdTimDatPlotChkForks.FalseValue = FALSE_VAL

Me.dgdTimDatPlotChkForks.NullValue = NULL_VAL

I need my checkboxes to not allow null; they must be either true or false,
with a default value of false.

However, when the app is run, they are always tri-state null (greyed out), &
even if they are changed to either true/false, as soon as the user navigates
from the column it returns to null.

Any suggestions as to what is wrong?


--
Cheers,
James Goodman MCSE, MCDBA
http://www.angelfire.com/sports/f1pictures
Nov 20 '05 #1
2 3339
Hi,

Here is an example which uses the northwind database. I assume you
have imports system.data.oledb at the top of your code file.

Dim conn As OleDbConnection

Dim strConn As String

Dim strSQL As String

Dim da As OleDbDataAdapter

Dim ds As New DataSet

strConn = "Provider = Microsoft.Jet.OLEDB.4.0;"

strConn &= "Data Source = Northwind.mdb;"

conn = New OleDbConnection(strConn)

da = New OleDbDataAdapter("Select * From Products", conn)

da.Fill(ds, "Products")

ds.Tables("Products").Columns("Discontinued").Defa ultValue = False

Dim ts As New DataGridTableStyle

ts.MappingName = ds.Tables("Products").TableName

Dim colDiscontinued As New DataGridBoolColumn

With colDiscontinued

..MappingName = "Discontinued"

..HeaderText = "Discontinued"

..Width = 80

End With

Dim colName As New DataGridTextBoxColumn

With colName

..MappingName = "ProductName"

..HeaderText = "Product Name"

..Width = 180

End With

ts.GridColumnStyles.Add(colName)

ts.GridColumnStyles.Add(colDiscontinued)

DataGrid1.TableStyles.Add(ts)

ts = Nothing

colDiscontinued = Nothing

colName = Nothing

DataGrid1.DataSource = ds.Tables("Products")

Ken

--------------------

"James Goodman" <j a m e s@norton-associates.co.u k> wrote in message
news:bu**********@hercules.btinternet.com...
I have a number of bool columns within a datagrid, but they dont work as
expected.

The underlying table is Access 2000. The datatype for the underlying
fields
is Yes/No.

I am attempting to create DataGridBoolColumns using the following code:

Private Const TRUE_VAL = -1

Private Const FALSE_VAL = 0

Private Const NULL_VAL = 0

Me.dgdTimDatPlotChkForks = New DataGridBoolColumn()

Me.dgdTimDatPlotChkForks.HeaderText = "FORKS"

Me.dgdTimDatPlotChkForks.MappingName = "FORKS"

Me.dgdTimDatPlotChkForks.Width = 75

Me.dgdTimDatPlotChkForks.AllowNull = False

Me.dgdTimDatPlotChkForks.TrueValue = TRUE_VAL

Me.dgdTimDatPlotChkForks.FalseValue = FALSE_VAL

Me.dgdTimDatPlotChkForks.NullValue = NULL_VAL

I need my checkboxes to not allow null; they must be either true or false,
with a default value of false.

However, when the app is run, they are always tri-state null (greyed out),
&
even if they are changed to either true/false, as soon as the user
navigates
from the column it returns to null.

Any suggestions as to what is wrong?


--
Cheers,
James Goodman MCSE, MCDBA
http://www.angelfire.com/sports/f1pictures

Nov 20 '05 #2
Ok, I have been looking at this.

I have managed to get the checkboxes to behave as they should (i.e.
true/false), but when I attempt to update the data-adapter I get a 'DataType
mismatch in criteria expression' error.

If I examine the value contained in the checkbox in question, its value will
be either True or False, as desired, so I dont think the problem is here.

I think the problem is a difference between a vb.net True value, & an Access
Yes/No True value.
Any ideas?

--
Cheers,
James Goodman MCSE, MCDBA
http://www.angelfire.com/sports/f1pictures
Nov 20 '05 #3

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

Similar topics

1
by: Erald Kulk | last post by:
I have a problem with a datagridboolcolumn that drives me almost crazy. I have a sql server table with several columns of which one is a column called ok which is a bit with default value 0. In...
0
by: subT | last post by:
created several tablestyles, added columstyles..added datagridboolcolumn to one of the collections.. I dont have a problem with the required 2 clicks to change a checkbox value, however, on the...
2
by: PeterZ | last post by:
Hi, In the past I've successfully databound a conventional Winforms checkbox to a number column in an Oracle table, where 1 represents true and 0 represents false. The checkbox would be ticked...
4
by: Ubi | last post by:
Hi, my code is: myDataTBL.Columns.Add("checked",System.Type.GetType("System.Boolean")); DataGridBoolColumn cs1 = new DataGridBoolColumn(); cs1.NullValue=false; cs1.TrueValue=true;...
1
by: Edward Koucherian | last post by:
I'm getting the incorrect display value on my DataGrid column. The field is numeric (1) in the SQL database table The Code is txtCol = New DataGridBoolColumn txtCol.MappingName = "MyCol"...
2
by: nate axtell | last post by:
I'm trying to create a custom DataGridBoolColumn. I inherit DataGridColumnStyle and create a public CheckBox variable. This columnType will be mapped to a dataTable boolean column. What are the...
1
by: B.J. Raiford | last post by:
I have a DataGrid on a form in my application that is bound to an xml file and I have set the table style to contain a few columns with one editable one, a DataGridBoolColumn. I set...
0
by: Ryan Liu | last post by:
Hi, I have a strange problem, should be very simple, take me days I couldn't finger out. Really appreciate if you can help me fine the problem. I am trying to use DataGridBoolColumn, but I...
0
by: Brett Romero | last post by:
I've created a DataGrid DataGridBoolColumn column in a tablestyle and mapped it correctly to a datatable. Problem is the column is always grayed and I can't uncheck it. I have the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.