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 Data Binding / July 2008

Tip: Looking for answers? Try searching our database.

display bit cols as "true"/"false"

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
John A Grandy - 26 Jun 2008 21:44 GMT
When binding a DataTable to a DataGridView , if the DataTable has a
non-nullable bit column ( 0 , 1 ) , is it possible to have 0 displayed as
"false" and 1 as "true" ?

NOTE: I need to keep the

DataGridView.DataSource = DataTable
DataGridView.Refresh()

syntax ...
Marc Gravell - 01 Jul 2008 08:10 GMT
Have you actually typed the column as bool/Boolean? It seems to work
fine for me (unless you are fussy about the casing). Example below. If
the DataTable is "typed" (i.e. SomeDataTable, SomeDataRow etc) rather
than a vanilla DataTable, you can do a lot by monkeying with the
TypeConverter on a per-property basis (I can elaborate if that would be
useful).

Marc

        DataTable dt = new DataTable();
        dt.Columns.Add("Foo", typeof(bool));
        dt.Rows.Add(false);
        dt.Rows.Add(true);
        Application.EnableVisualStyles();
        Application.Run(
            new Form {
                Controls = {
                    new DataGridView {
                        Columns = {
                            new DataGridViewTextBoxColumn {
                                 DataPropertyName = "Foo"
                            }
                        },
                        Dock = DockStyle.Fill,
                        DataSource = dt
                    }
                }
            });

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.