Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 2005 > C# 2005
|
C# 2005 For discussion of Visual C# 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 15th, 2008, 12:18 AM
Registered User
 
Join Date: Feb 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default DataGridViewCheckBoxColumn as a Check Box

Hi,
I have a DataGridView in my designer with
Column1 as DataGridViewCheckBoxColumn and
Column2 as DataGridViewCheckTextColumn.
DataGridViewCheckBoxColumn should work as a CheckBox i.e. multiple selections are not allowed.
I tried to handle it in EventHandler but of no use.
if I try to click a second check box when one is already checked getting the following error.
---------------------------
DataGridView Default Error Dialog
---------------------------
The following exception occurred in the DataGridView:



System.FormatException: Checked is not a valid value for Boolean. ---> System.FormatException: String was not recognized as a valid Boolean.

   at System.Boolean.Parse(String value)

   at System.ComponentModel.BooleanConverter.ConvertFrom (ITypeDescriptorContext context, CultureInfo culture, Object value)

   --- End of inner exception stack trace ---

   at System.ComponentModel.BooleanConverter.ConvertFrom (ITypeDescriptorContext context, CultureInfo culture, Object value)

   at System.Windows.Forms.Formatter.FormatObjectInterna l(Object value, Type targetType, TypeConverter sourceConverter, TypeConverter targetConverter, String formatString, IFormatProvider formatInfo, Object formattedNullValue)

   at System.Windows.Forms.Formatter.FormatObject(Object value, Type targetType, TypeConverter sourceConverter, TypeConverter targetConverter, String formatString, IFormatProvider formatInfo, Object formattedNullValue, Object dataSourceNullValue)

   at System.Windows.Forms.DataGridViewCell.GetFormatted Value(Object value, Int32 rowIndex, DataGridViewCellStyle& cellStyle, TypeConverter valueTypeConverter, TypeConverter formattedValueTypeConverter, DataGridViewDataErrorContexts context)



To replace this default dialog please handle the DataError event.
---------------------------
OK
---------------------------


Any help in this context how I can suffice my aim are appreciated.

Thanks & Regards,
Supriya
 
Old February 15th, 2008, 12:23 AM
Friend of Wrox
 
Join Date: Oct 2007
Posts: 130
Thanks: 0
Thanked 3 Times in 3 Posts
Send a message via AIM to urtrivedi
Default

As far as my knowledge,
1) I think the basic column should have boolean, bit or number data type.
2) Try to set datagrid column property, allow null or tristate to false.


urt

Help yourself by helping someone.
 
Old February 15th, 2008, 12:38 AM
Registered User
 
Join Date: Feb 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi urt,
Thanks for your reply.
But Tristate is already set to False. :(

Thanks & Regards,
Supriya
 
Old February 15th, 2008, 05:37 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

Is this error occurring in the event handler you wrote?

It appears to be trying to convert the string "Checked" to a boolean.

/- Sam Judson : Wrox Technical Editor -/





Similar Threads
Thread Thread Starter Forum Replies Last Post
check box help? dstein4d Access VBA 2 February 27th, 2008 09:54 AM
Check BOx kaushikpulpa ASP.NET 2.0 Professional 2 August 30th, 2007 08:01 AM
DataGridViewCheckBoxColumn Value Problem erictamlam C# 2005 2 April 23rd, 2007 10:01 AM
please help (get check box value) qadeerahmad General .NET 3 September 24th, 2004 08:46 AM
how to get value from check box..... cici Classic ASP Professional 2 May 15th, 2004 08:35 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.