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 Controls / December 2006

Tip: Looking for answers? Try searching our database.

Let DataGridView interpret -1 as null value (C++/CLI)

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
maik.wiege@googlemail.com - 13 Dec 2006 10:34 GMT
Hello,
I'm developing in C++/CLI and using a DataGridView that is bound to a
BindingSource that uses a list of objects of my my custom class. This
objects have some properties that are displayed in the columns of the
datagrid. Some of these properties are of type int and therefor do not
have a null value (nullptr). In my program I internaly use -1 as the
meaning of "not set".
Is there a way to let the DataGridView display that property values as
null values instead of displaying the -1, meaning displaying just an
empty cell?
I don't think that this is possible using custom formatation of the
column, but I do not want to override the whole DataGridView class.

Does anyone have a nice and simple idea how one could accomplish that?

Thanks
 Maik Wiege
Kevin Spencer - 13 Dec 2006 12:45 GMT
Use a nullable int. The syntax is:

int? i = 0;
i = null;

// etc.

This is a System.Nullable<int>

Signature

HTH,

Kevin Spencer
Microsoft MVP
Bit Player
http://unclechutney.blogspot.com

Expect the unaccepted.

> Hello,
> I'm developing in C++/CLI and using a DataGridView that is bound to a
[quoted text clipped - 13 lines]
> Thanks
>  Maik Wiege
maik.wiege@googlemail.com - 13 Dec 2006 14:24 GMT
Thanks Kevin,

I didn't want to do that, bacause than I have to rewrite many parts in
my code and I'm having some perfomancy doubts about it, but it seems
that it is my only chance.

Thanks again
 Maik

Kevin Spencer schrieb:

> Use a nullable int. The syntax is:
>
[quoted text clipped - 32 lines]
> > Thanks
> >  Maik Wiege

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.