472,975 Members | 1,491 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Datagrid and money format problems (BUG?)

Hi all,

I'm getting a bug with the datagrid object.
I've created one from scratch, bound it to a dataview with 2 int32
columns and formatted the output as currency.

I've found that when you use the F2 key to enter edit mode and then
hit TAB or ESCAPE without actually editing the value, dotnet crashes
with a null reference error.

Any takers?

To replicate this problem, create a new form, add a datagrid and add a
tablestyle with two columns, mapping to col1 and col2.
Set the format of col1 to "c" and put this in the constuctor:

DataTable loTable = new DataTable();
loTable.Columns.Add("col1", typeof(Int32));
loTable.Columns.Add("col2", typeof(Int32));

this.dataGrid1.DataSource = loTable.DefaultView;
loTable.Rows[0]["col1"] = 1234;
loTable.Rows[0]["col2"] = 5678;

Run it, and hit F2 on the first cell, and then TAB.

I've also noticed that it won't crash if there's only one column.

Please help!
Tamlin Cowgill
Jul 21 '05 #1
2 3189

I could not reproduce your problem. I have installed the sp1 for Net 1.1

Jul 21 '05 #2
It must be something else, I've just installed SP 1 for .Net FWK 1.1
this morning and I'm still getting the same problems.

Can anybody else replicate this problem?

I'm using:
Microsoft Development Environment 2003, Version 7.1.3088
Microsoft .Net Framework 1.1 Version 1.1.4322 SP1
Microsoft Windows 2000 SP4
I also had VSIP installed but have since had it removed.
Here's the entire form code:
//Cut Here: --------------------------------------------------
using System;
using System.Drawing;
using System.Collections;,
using System.Windows.Forms;
using System.Data;

namespace Products
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
private System.Windows.Forms.DataGrid dataGrid1;
private System.Windows.Forms.DataGridTableStyle dataGridTableStyle1;
private System.Windows.Forms.DataGridTextBoxColumn
private System.Windows.Forms.DataGridTextBoxColumn
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;

public Form1()
// Required for Windows Form Designer support

// TODO: Add any constructor code after InitializeComponent call
DataTable loTable;
DataRow loRow;
loTable = new DataTable();
loTable.Columns.Add("col1", typeof(Int32));
loTable.Columns.Add("col2", typeof(Int32));
dataGrid1.DataSource = loTable;
loRow = loTable.NewRow();
loRow["col1"] = 1234;
loRow["col2"] = 5678;
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
if( disposing )
if(components != null)
base.Dispose( disposing );

#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
this.dataGrid1 = new System.Windows.Forms.DataGrid();
this.dataGridTableStyle1 = new
this.dataGridTextBoxColumn1 = new
this.dataGridTextBoxColumn2 = new
((System.ComponentModel.ISupportInitialize)(this.d ataGrid1)).BeginInit();
// dataGrid1
this.dataGrid1.DataMember = "";
this.dataGrid1.HeaderForeColor =
this.dataGrid1.Location = new System.Drawing.Point(8, 8);
this.dataGrid1.Name = "dataGrid1";
this.dataGrid1.Size = new System.Drawing.Size(280, 264);
this.dataGrid1.TabIndex = 0;
System.Windows.Forms.DataGridTableStyle[] {
// dataGridTableStyle1
this.dataGridTableStyle1.DataGrid = this.dataGrid1;
this.dataGridTableStyle1.GridColumnStyles.AddRange (new
System.Windows.Forms.DataGridColumnStyle[] {
this.dataGridTableStyle1.HeaderForeColor =
this.dataGridTableStyle1.MappingName = "";
// dataGridTextBoxColumn1
this.dataGridTextBoxColumn1.Format = "c";
this.dataGridTextBoxColumn1.FormatInfo = null;
this.dataGridTextBoxColumn1.MappingName = "col1";
this.dataGridTextBoxColumn1.Width = 75;
// dataGridTextBoxColumn2
this.dataGridTextBoxColumn2.Format = "c";
this.dataGridTextBoxColumn2.FormatInfo = null;
this.dataGridTextBoxColumn2.MappingName = "col2";
this.dataGridTextBoxColumn2.Width = 75;
// Form1
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 273);
this.Name = "Form1";
this.Text = "Form1";
((System.ComponentModel.ISupportInitialize)(this.d ataGrid1)).EndInit();

// To Here:----------------------------------------------

And here's the output
Unhandled Exception: System.NullReferenceException: Object reference
not set to an instance of an object.
at System.Windows.Forms.DataGrid.CommitEdit()
at System.Windows.Forms.DataGrid.EndEdit()
at System.Windows.Forms.DataGrid.Edit(String instantText)
at System.Windows.Forms.DataGrid.Edit()
at System.Windows.Forms.DataGrid.set_CurrentCell(Data GridCell
at System.Windows.Forms.DataGrid.set_CurrentColumn(In t32 value)
at System.Windows.Forms.DataGrid.ProcessTabKey(Keys keyData)
at System.Windows.Forms.DataGrid.ProcessGridKey(KeyEv entArgs ke)
at System.Windows.Forms.DataGrid.ProcessDialogKey(Key s keyData)
at System.Windows.Forms.Control.ProcessDialogKey(Keys keyData)
at System.Windows.Forms.TextBoxBase.ProcessDialogKey( Keys keyData)
at System.Windows.Forms.Control.PreProcessMessage(Mes sage& msg)
at System.Windows.Forms.ThreadContext.System.Windows. Forms.UnsafeNativeMethods+IMsoComponent.FPreTransl ateMessage(MSG&
at System.Windows.Forms.ComponentManager.System.Windo ws.Forms.UnsafeNativeMethods+IMsoComponentManager. FPushMessageLoop(Int32
dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.ThreadContext.RunMessageLoopI nner(Int32
reason, ApplicationContext context)
at System.Windows.Forms.ThreadContext.RunMessageLoop( Int32 reason,
ApplicationContext context)
at System.Windows.Forms.Application.RunDialog(Form form)
at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
at System.Windows.Forms.Form.ShowDialog()
at Products.App.Main(String[] asArgs) in
c:\dotnet\productmigration\products\classes\app.cs :line 53The program
'[1420] Products.exe' has exited with code 0 (0x0).

Jul 21 '05 #3

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

Similar topics

by: Andres Romero | last post by:
I have a button in my html page for exporting to excel files using the RenderControl function. When the table generated is small in rows size it works fine, but when there are much more rows (more...
by: sdbranum | last post by:
I have been using Visual C#.NET to code a large project having many data adapters, data sets, datagrids, multiple forms with tab pages, each containing various controls (mostly label, text boxes,...
by: Henrique Berenguel | last post by:
Hello folks. I have a DataGrid in a Web Form. IŽd like to show numeric columns in Money format US$ 10,000.98. However, when I fill the DataGrid from a SqlCommand, it fill in the DataGrid like this:...
by: D. Shane Fowlkes | last post by:
I have a couple of fields in SQL Server which are defined as "Money". One is "Quantity" and the other is "Unit Price". Unit Price I can understand being defined as "money" but I'm not sure why the...
by: Jensen bredal | last post by:
Hello gurus, How do i handle Currencies from "asp.net form field " to "insert " querry in database? The "money" is entered in a textbox and my code is falling to the stored procedure due to...
by: Beren | last post by:
Hi all I'm almost braindead on this one, but how can I create a master/detail datagrid in this format : CatA subcatA1 subcatA2 subcatA3
by: pmcguire | last post by:
I have derived a ComboBoxColumnStyle that inherits DataGridColumnStyle. It works fine except for one behavior. If the user selects a new value from the ComboBox's pulldown list on a brand new...
by: Earl | last post by:
Still trying to clean up some datagrid formatting issues from the past. When I bring in money values from a stored procedure, I'm getting 4 decimal places in the grid ( which of course I only...
by: Tamlin | last post by:
Hi all, I'm getting a bug with the datagrid object. I've created one from scratch, bound it to a dataview with 2 int32 columns and formatted the output as currency. I've found that when you...
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.