473,800 Members | 2,607 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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

An unhandled exception of type 'System.NullRef erenceException ' occurred in
WindowsApplicat ion1.exe

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

Please help me.

Thanks

Michael

CODE:
=====
private void CreateMyDatagri d()

{

// MyDatagrid erstellen

DataGrid MyDataGrid = new DataGrid();

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

// Datagrid Eigenschaften

MyDataGrid.Capt ionText="Berech tigung -> ALLE = A+B+E+L / A=Ansehen /
B=Bearbeiten / E = Erstellen / L=Löschen";

MyDataGrid.Read Only = false;

// Dataset erstellen

DataSet MyDataSet = new DataSet();
DataGridTableSt yle myTableStyle = new DataGridTableSt yle();

myTableStyle.Ma ppingName = "MappingName_ts _berechtigung"; // ts=tablestyle

DataGridBoolCol umn boolCol = new DataGridBoolCol umn();

boolCol.Mapping Name="MappingNa me_dgbc_berecht igung";
//dgbc=datagridbo olcolumn

((DataGridBoolC olumn)boolCol). AllowNull = false;

myTableStyle.Gr idColumnStyles. Add(boolCol);

//MyDataGrid.Tabl eStyles.Clear() ;

// DataTable erstellen

DataTable dt = new DataTable("Data Table_Berechtig ung");
// 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.Gr idColumnStyles["Modul"].Width=20;

myTableStyle.Gr idColumnStyles["Zusatz..."].Width=50;

myTableStyle.Gr idColumnStyles["ALLE"].Width=60;

//MyDataGrid.Tabl eStyles["DataTable_Bere chtigung"].GridColumnStyl es[0].Width
=0;

//MyDataGrid.Tabl eStyles["DataTable_Bere chtigung"].GridColumnStyl es[1].Width
=80;

//MyDataGrid.Tabl eStyles["DataTable_Bere chtigung"].GridColumnStyl es[2].Width
=80;

//MyDataGrid.Tabl eStyles["DataTable_Bere chtigung"].GridColumnStyl es[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.Table s.Add(dt);
// Dataset in datagrid

MyDataGrid.SetD ataBinding(MyDa taSet,"DataTabl e_Berechtigung" );

// Tablestyle dem Datagrid hinzufügen

MyDataGrid.Tabl eStyles.Add(myT ableStyle);
// Anzeigen des Datagrids

this.Controls.A dd(MyDataGrid);

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

An unhandled exception of type 'System.NullRef erenceException ' occurred
in WindowsApplicat ion1.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.Gr idColumnStyles["Modul"].Width=20;
myTableStyle.Gr idColumnStyles["Zusatz..."].Width=50;
myTableStyle.Gr idColumnStyles["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******** *****@TK2MSFTNG P12.phx.gbl:

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

An unhandled exception of type 'System.NullRef erenceException ' occurred
in WindowsApplicat ion1.exe

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

Please help me.
// Spalten erstellen

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


...
//Spaltenbreite definieren

myTableStyle. GridColumnStyle s["Modul"].Width=20;
myTableStyle. GridColumnStyle s["Zusatz..."].Width=50;
myTableStyle. GridColumnStyle s["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******** *****@TK2MSFTNG P12.phx.gbl:

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

An unhandled exception of type 'System.NullRef erenceException ' occurred
in WindowsApplicat ion1.exe

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

Please help me.
// Spalten erstellen

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


...
//Spaltenbreite definieren

myTableStyle. GridColumnStyle s["Modul"].Width=20;
myTableStyle. GridColumnStyle s["Zusatz..."].Width=50;
myTableStyle. GridColumnStyle s["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

DataGridTableSt yle myTableStyle = new DataGridTableSt yle();

myTableStyle.Ma ppingName = "DataTable_Bere chtigung";

MyDataGrid.Tabl eStyles.Clear() ;
// Spalten-Eigenschaften

DataGridTextBox Column Col_0 = new DataGridTextBox Column();

Col_0.MappingNa me="Modul";

Col_0.Width = 150;

Col_0.ReadOnly = true;

Col_0.HeaderTex t = "Module";

DataGridBoolCol umn Col_1 = new DataGridBoolCol umn();

Col_1.MappingNa me="ALLE";

Col_1.Width = 60;

Col_1.AllowNull = false;

Col_1.HeaderTex t = "ALLE";

Col_1.Alignment = System.Windows. Forms.Horizonta lAlignment.Cent er;

DataGridBoolCol umn Col_2 = new DataGridBoolCol umn();

......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
244
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 information: Object reference not set to an instance of an object. Please help me.
6
3135
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 I keep getting a message that the object is not referenced. What I am trying to do is be information from text boxes and insert them into a new row in a dataset. The application has several tabs of information. I have a button set up so they...
2
1977
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 'System.NullReferenceException' occurred in system.data.dll Additional information: Object reference not set to an instance of an object. Code:
4
1404
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 unhandled exception of type 'System.NullReferenceException' occurred in system.windows.forms.dll 'Additional information: Object reference not set to an instance of an object.
1
1270
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 nrtb As New RichTextBox Sub DisplayMessage(ByVal rtb As RichTextBox, ByVal sText As String, Optional ByVal Colour As String = "") rtb.SelectionStart = rtb.Text.Length ' rtb.doColor(rtb, DirectCast(sText, String))
12
5558
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. Foo = function(type) { this.num = 0; this.type = type this.trigger(); } Foo.prototype.trigger = function() {
6
2482
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
2659
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
11116
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. Here is a newbie mistake that I found myself doing (as a newbie), and that even a master programmer, the guru of this forum, Jon Skeet, missed! (He knows this I'm sure, but just didn't think this was my problem; LOL, I am needling him) If...
0
9690
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9550
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10273
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9085
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6811
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5469
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5603
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4149
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2944
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.