Re: Format grid column to display "" instead of datetime DBNull (1

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Hi Chris,

The error is at runtime. It says "object not set to an instance". I know
the grid is not the problem as I can see it after it is populated.
I think it refers to the TableStyles object within the Grid. I Added the
following line to verify:

int nStyles = oGrid.TableStyles.Count;

nStyles value is zero. I was expecting a value of 1 as the grid was
populated from a table.

Just in case you are wondering, the column formatting setGridColumnStyle()
is called after the grid is populated.

Any Ideas?

Thank you,

Carlos Lozano

"Chris" wrote:

> Carlos Lozano wrote:
> > Hello Folks!
> >
> > I have a grid that populates from a table on SQL Server. All datetime with
> > DBNull value show 1/1/1900 12:00AM ... Instead of just blank ("").
> >
> > I found a document with the following code, but didn't work.
> >
> > public void setGridColumnStyle()
> > {
> > DataGridColumnStyle newColStyle;
> > newColStyle = oGrid.TableStyles[0].GridColumnStyles[0];
> > newColStyle.NullText = "";
> > }
> >
> > I tried to customize it to my needs as below:
> > public void setGridColumnStyle(ref System.Windows.Forms.Grid oGrid, string
> > sTable, string sColumn)
> > {
> > DataGridColumnStyle newColStyle;
> > newColStyle = oGrid.TableStyles[sTable].GridColumnStyles[sColumn];
> > newColStyle.NullText = "";
> > }
> >
> > I always got an error on second line.
> >
> > I will appreciate any help to do this.
> >
> > Carlos Lozano
> > www.caxonline.net
>
>
> What is the error? Is the error at runtime or design time...
>
> Chris
>
.



Relevant Pages

  • Re: dbGo in Delphi 2006
    ... I just installed Delphi 2006. ... I have a table that populates a grid. ... property of the DBGrid and the DataSet property of the DataSource ...
    (borland.public.delphi.database.ado)
  • Re: dbGo in Delphi 2006
    ... I have a table that populates a grid. ... When a TAdoQuery is opened in the IDE, the grid is populated. ...
    (borland.public.delphi.database.ado)
  • Re: Format grid column to display "" instead of datetime DBNull (1
    ... Carlos Lozano wrote: ... I know the grid is not the problem as I can see it after it is populated. ... I have a grid that populates from a table on SQL Server. ... DataGridColumnStyle newColStyle; ...
    (microsoft.public.dotnet.languages.csharp)
  • dbGo in Delphi 2006
    ... I have a table that populates a grid. ... When a TAdoQuery is opened in the ... IDE, the grid is populated. ...
    (borland.public.delphi.database.ado)