VS.NET does not Assign DataGridBoolColumn TrueValue and FalseValue Properties Correctly - The DataGridBoolColumn object in a DataGrid will not appear or function correctly when setting the TrueValue and FalseValue properties explicitly in VS.NET.
The LBTT Spot
"Lifeline is focused on developing and marketing systems designed to assist in the early detection of breast and ovarian cancer."



VS.NET does not Assign DataGridBoolColumn TrueValue and FalseValue Properties Correctly

View C# Source Code

Article Categories:

.Net Framework
.Net Framework 1.1
ADO.NET
ASP.NET
Assemblies
Asynchronous Methods
C#
Collections
Configuration
Delegates
Events
Pocket PC
Regular Expressions
Smart Devices
SQL Server
Visual C#
Visual Studio .NET
Visual Studio .NET 2003
Windows Forms
XML

C# .Net Fun Menu

View Current Page's ASP.NET Source Code
C# Reference
C# Study Flash Cards
Valuable Links
Contact Us
Site Map
Mike's Portfolio

C# Reference Search:

Full Text Search:

Articles by Author:

Code Examples (zipped):

VS.NET does not Assign DataGridBoolColumn TrueValue and FalseValue Properties Correctly

The DataGridBoolColumn object in a DataGrid will not appear or function correctly when setting the TrueValue and FalseValue properties explicitly in VS.NET.
Category: Windows Forms, Visual Studio .NET, Posted 11/12/2003, By Mike G.

If you are populating a DataGrid in your Windows Forms application and are using a TableStyle to define custom columns, you will not get a DataGridBoolColumn to correctly save or retrieve boolean values from your DataSet. This will occur IF you manually set the TrueValue and FalseValue properties of the DataGridBoolColumn object in the designer explicitly. This occurs because the designer will convert whetever you type in those two properties to System.String values - not System.Boolean values.

You should explicitly set the TrueValue and FalseValue properties of the DataGridBoolColumn object to actual boolean values as shown below. private void frmMyForm_Dates_Load(object sender, System.EventArgs e) { // other Loading event code .... // This is what the VS.NET designer does: dataGridBoolColumn1.TrueValue = "True"; dataGridBoolColumn1.FalseValue = "False"; // The preceding causes a problem because the DataSet Column used with this // column is of type System.Boolean and NOT System.String. // So, change it to something like the following to fix the problem: dataGridBoolColumn1.TrueValue = true; dataGridBoolColumn1.FalseValue = false; } Note: this will only pose a problem IF your DataSet is expecting an actual boolean value; otherwise, you put whatever value you want for a boolean substitute.