473,388 Members | 1,286 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

Additional information: Object reference not set to an instance of an object.

I get this message in "Spaltenbreite definieren" => Definition for Columns
Width

An unhandled exception of type 'System.NullReferenceException' occurred in
WindowsApplication1.exe

Additional information: Object reference not set to an instance of an
object.

Please help me.

Thanks

Michael

CODE:
=====
private void CreateMyDatagrid()

{

// MyDatagrid erstellen

DataGrid MyDataGrid = new DataGrid();

MyDataGrid.Bounds = new Rectangle(new Point(10,10), new Size(650,350));

// Datagrid Eigenschaften

MyDataGrid.CaptionText="Berechtigung -> ALLE = A+B+E+L / A=Ansehen /
B=Bearbeiten / E = Erstellen / L=Löschen";

MyDataGrid.ReadOnly = false;

// Dataset erstellen

DataSet MyDataSet = new DataSet();
DataGridTableStyle myTableStyle = new DataGridTableStyle();

myTableStyle.MappingName = "MappingName_ts_berechtigung"; // ts=tablestyle

DataGridBoolColumn boolCol = new DataGridBoolColumn();

boolCol.MappingName="MappingName_dgbc_berechtigung ";
//dgbc=datagridboolcolumn

((DataGridBoolColumn)boolCol).AllowNull = false;

myTableStyle.GridColumnStyles.Add(boolCol);

//MyDataGrid.TableStyles.Clear();

// DataTable erstellen

DataTable dt = new DataTable("DataTable_Berechtigung");
// Spalten erstellen

dt.Columns.Add("Modul", typeof(string)).ReadOnly = true;

dt.Columns.Add("Zusatz...", typeof(string)).ReadOnly = true;

dt.Columns.Add("ALLE", typeof(bool));

dt.Columns.Add("A", typeof(bool));

dt.Columns.Add("B", typeof(bool));

dt.Columns.Add("E", typeof(bool));

dt.Columns.Add("L", typeof(bool));

//Spaltenbreite definieren

myTableStyle.GridColumnStyles["Modul"].Width=20;

myTableStyle.GridColumnStyles["Zusatz..."].Width=50;

myTableStyle.GridColumnStyles["ALLE"].Width=60;

//MyDataGrid.TableStyles["DataTable_Berechtigung"].GridColumnStyles[0].Width
=0;

//MyDataGrid.TableStyles["DataTable_Berechtigung"].GridColumnStyles[1].Width
=80;

//MyDataGrid.TableStyles["DataTable_Berechtigung"].GridColumnStyles[2].Width
=80;

//MyDataGrid.TableStyles["DataTable_Berechtigung"].GridColumnStyles[3].Width
=20;

// Zeilen erstellen und inhalt abfüllen

// checkbox in variable

int test = 1;

dt.Rows.Add(new Object[] {"Adresse", "ev. sonst noch was",0,test,0,0,0});

dt.Rows.Add(new Object[] {"Depositen", "ev. sonst noch was",1,1,1,1,1});

dt.Rows.Add(new Object[] {"Obligation", "ev. sonst noch was",0,0,0,0,0});

dt.Rows.Add(new Object[] {"Miete", "ev. sonst noch was",1,1,1,1,1});

dt.Rows.Add(new Object[] {"Stammdaten", "ev. sonst noch was",0,0,0,0,0});

// DataTable in dataset

MyDataSet.Tables.Add(dt);
// Dataset in datagrid

MyDataGrid.SetDataBinding(MyDataSet,"DataTable_Ber echtigung");

// Tablestyle dem Datagrid hinzufügen

MyDataGrid.TableStyles.Add(myTableStyle);
// Anzeigen des Datagrids

this.Controls.Add(MyDataGrid);

}
Nov 16 '05 #1
4 5949
"michael walser" <mi************@bingo.de> wrote in
news:eZ*************@TK2MSFTNGP12.phx.gbl:
I get this message in "Spaltenbreite definieren" => Definition for
Columns Width

An unhandled exception of type 'System.NullReferenceException' occurred
in WindowsApplication1.exe

Additional information: Object reference not set to an instance of an
object.

Please help me.
// Spalten erstellen

dt.Columns.Add("Modul", typeof(string)).ReadOnly = true;
dt.Columns.Add("Zusatz...", typeof(string)).ReadOnly = true;
dt.Columns.Add("ALLE", typeof(bool)); .... //Spaltenbreite definieren

myTableStyle.GridColumnStyles["Modul"].Width=20;
myTableStyle.GridColumnStyles["Zusatz..."].Width=50;
myTableStyle.GridColumnStyles["ALLE"].Width=60;


In the debugger, could you please check if these column styles are
actually defined? You probably should add a new GridColumnStyle first.

Frans.

--
Get LLBLGen Pro, the new O/R mapper for .NET: http://www.llblgen.com
My .NET Blog: http://weblogs.asp.net/fbouma
Microsoft C# MVP
Nov 16 '05 #2
Frans Bouma [C# MVP] wrote:
"michael walser" <mi************@bingo.de> wrote in
news:eZ*************@TK2MSFTNGP12.phx.gbl:

I get this message in "Spaltenbreite definieren" => Definition for
Columns Width

An unhandled exception of type 'System.NullReferenceException' occurred
in WindowsApplication1.exe

Additional information: Object reference not set to an instance of an
object.

Please help me.
// Spalten erstellen

dt.Columns.Add("Modul", typeof(string)).ReadOnly = true;
dt.Columns.Add("Zusatz...", typeof(string)).ReadOnly = true;
dt.Columns.Add("ALLE", typeof(bool));


...
//Spaltenbreite definieren

myTableStyle.GridColumnStyles["Modul"].Width=20;
myTableStyle.GridColumnStyles["Zusatz..."].Width=50;
myTableStyle.GridColumnStyles["ALLE"].Width=60;

In the debugger, could you please check if these column styles are
actually defined? You probably should add a new GridColumnStyle first.

Frans.

Yes? that's right. I met with this error many time.
Nov 16 '05 #3
Frans Bouma [C# MVP] wrote:
"michael walser" <mi************@bingo.de> wrote in
news:eZ*************@TK2MSFTNGP12.phx.gbl:

I get this message in "Spaltenbreite definieren" => Definition for
Columns Width

An unhandled exception of type 'System.NullReferenceException' occurred
in WindowsApplication1.exe

Additional information: Object reference not set to an instance of an
object.

Please help me.
// Spalten erstellen

dt.Columns.Add("Modul", typeof(string)).ReadOnly = true;
dt.Columns.Add("Zusatz...", typeof(string)).ReadOnly = true;
dt.Columns.Add("ALLE", typeof(bool));


...
//Spaltenbreite definieren

myTableStyle.GridColumnStyles["Modul"].Width=20;
myTableStyle.GridColumnStyles["Zusatz..."].Width=50;
myTableStyle.GridColumnStyles["ALLE"].Width=60;

In the debugger, could you please check if these column styles are
actually defined? You probably should add a new GridColumnStyle first.

Frans.

Yes, that's right. I met with this error many time.
Nov 16 '05 #4
Yes it works.

// Tablestyle erstellen

DataGridTableStyle myTableStyle = new DataGridTableStyle();

myTableStyle.MappingName = "DataTable_Berechtigung";

MyDataGrid.TableStyles.Clear();
// Spalten-Eigenschaften

DataGridTextBoxColumn Col_0 = new DataGridTextBoxColumn();

Col_0.MappingName="Modul";

Col_0.Width = 150;

Col_0.ReadOnly = true;

Col_0.HeaderText = "Module";

DataGridBoolColumn Col_1 = new DataGridBoolColumn();

Col_1.MappingName="ALLE";

Col_1.Width = 60;

Col_1.AllowNull = false;

Col_1.HeaderText = "ALLE";

Col_1.Alignment = System.Windows.Forms.HorizontalAlignment.Center;

DataGridBoolColumn Col_2 = new DataGridBoolColumn();

......etc etc..

Thanks for your help

Michael
Nov 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: michael walser | last post by:
I get this message in "Spaltenbreite definieren" => Definition for Columns Width An unhandled exception of type 'System.NullReferenceException' occurred in WindowsApplication1.exe Additional...
6
by: Christopher Young | last post by:
I have several user controls on a page and I am trying to get information out of them. The postback is being caused on the aspx page and not in the user control. I have tried using a property but...
2
by: Brad | last post by:
Receive the following error when stepping into the FILL (see last line). Being a newbie I cannot see anything obvious. Error message: An unhandled exception of type...
4
by: Supra | last post by:
I am doing irc chat similar to mirc chat if i connected to irc.webamster.com i had no problem. but if connected to eu.undernet.org. i got error....somthing bug me! O:-) 'February 2004 'An...
1
by: Supra | last post by:
'An unhandled exception of type 'System.NullReferenceException' occurred in system.windows.forms.dll 'Additional information: Object reference not set to an instance of an object. in module: Dim...
12
by: Andrew Poulos | last post by:
With the following code I can't understand why this.num keeps incrementing each time I create a new instance of Foo. For each instance I'm expecting this.num to alert as 1 but keeps incrementing. ...
6
by: Shailen Sukul | last post by:
Observed a weird behaviour with object references. See code listing below: using System; using System.Collections.Generic; using System.Text; namespace PointerExceptionTest { /*
2
by: Ralph | last post by:
Hi I don't understand why it's not working: function schedule(imTop){ this.tdImagesTop = imTop; } schedule.prototype.selectEl = function() { alert(this.tdImagesTop);
12
by: raylopez99 | last post by:
Keywords: scope resolution, passing classes between parent and child forms, parameter constructor method, normal constructor, default constructor, forward reference, sharing classes between forms....
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.