Helpppppppppppp

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

what is wrong with that code
i only want to replace any Null Value in the DataGrid to a space value
it tells me object not set to an instance
this.DG_U=new System.Windows.Forms.DataGrid();


this.DG_U.TableStyles.AddRange(new
System.Windows.Forms.DataGridTableStyle[] {
this.DG_UTableStyle});
this.DG_UTableStyle.GridColumnStyles.AddRange(new
System.Windows.Forms.DataGridColumnStyle[] {
this.DG_UTextBoxColumn});
the error appears at this point

DG_U.DataSource =DS_U.Tables[0];
DG_U.Size = this.tabPage_U.Size;
this.DG_UTableStyle = new System.Windows.Forms.DataGridTableStyle();
this.DG_UTextBoxColumn = new System.Windows.Forms.DataGridTextBoxColumn();

// DGFaculities
this.DG_UTextBoxColumn.NullText =" ";
this.DG_UTableStyle.DataGrid = this.DG_U;

when i try to make instance of
this.DG_UColumnStyle = new System.Windows.Forms.DataGridColumnStyle();
it tells me it's an abstract class & cant creat instance of it
how to make ittttttttttt

Regards
 
tota said:
when i try to make instance of
this.DG_UColumnStyle = new System.Windows.Forms.DataGridColumnStyle();
it tells me it's an abstract class & cant creat instance of it
The answer is in your question. DataGridColumnStyle is an abstract
class. An abstract calls is a class that contains one or more abstract
methods, and therefore can never be instantiated. Abstract classes are
defined so that other classes can extend them and make them concrete by
implementing the abstract methods.

There are two classes in the System.Windows.Forms namespace that extend
this class; DataGridBoolColumn and DataGridTextBoxColumn.

Anders Norås
http://dotnetjunkies.com/weblog/anoras/
 
Tota,

I see a lot code however,

Basicly you only need to contruct a DatagridTableStyle
Add to that a constructed DataGridTextBoxColumn
Set the Mappingname of the DataGridTableStyle to the datatablename
Set the Mappingname of the DataGridTextBoxColumn to the field name
Set the property NullText in the DataGridTextBoxColumn to ""
Add the DatagridTableStyle to your DataGrid.TableStyles

I thought that this should do it.

I hope this helps?

Cor
 
Also, as an aside, a subject line like "Helppppppp" doesn't garner nearly as
many useful responses as something that actually describes the problem, such
as, "Problem displaying null values in a WinForms DataGrid".

I always cringe at subject lines like that, and usually never read the
message because 95% of the time they are vague questions with insufficient
info to help the person anyway.

--Bob
 
Back
Top