Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / March 2006

Tip: Looking for answers? Try searching our database.

Problem with DataGridBoolColumn

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Yossi And Inbar - 23 Mar 2006 22:57 GMT
Hi,

I am using VS2003 C# and i have a problem with DataGridBoolColumn.

I am using DataGridBoolColumn for show open/close Value, but the column not
work like i need :

1) The columns are gray. all other columns are ok.

2) The values at the column are allways true, not like in the database. ( In
the database the column is Bit type column with 0/1 values).

I change all ReadOnly values to false and all AllowNull property to false,
but its not solve the problem I add the column into DataGridStyle by .Net
style wizard...

What's wrong here ?

How can i solve the problem ?

Thanks,

Yossi
Song Huang - 29 Mar 2006 20:27 GMT
Microsoft's Bug:

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

> Hi,
>
[quoted text clipped - 19 lines]
>
> Yossi

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.