473,770 Members | 2,065 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Default View;
loTable.Rows.Ad d(loTable.NewRo w());
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!
Thanks,
Tamlin Cowgill
Jul 21 '05 #1
2 3275
Tamlin,

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

Cor
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.Collecti ons;,
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.DataGridT ableStyle dataGridTableSt yle1;
private System.Windows. Forms.DataGridT extBoxColumn
dataGridTextBox Column1;
private System.Windows. Forms.DataGridT extBoxColumn
dataGridTextBox Column2;
/// <summary>
/// Required designer variable.
/// </summary>
private System.Componen tModel.Containe r components = null;

public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeCompo nent();

//
// TODO: Add any constructor code after InitializeCompo nent call
//
DataTable loTable;
DataRow loRow;
loTable = new DataTable();
loTable.Columns .Add("col1", typeof(Int32));
loTable.Columns .Add("col2", typeof(Int32));
dataGrid1.DataS ource = loTable;
loRow = loTable.NewRow( );
loTable.Rows.Ad d(loRow);
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)
{
components.Disp ose();
}
}
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 InitializeCompo nent()
{
this.dataGrid1 = new System.Windows. Forms.DataGrid( );
this.dataGridTa bleStyle1 = new
System.Windows. Forms.DataGridT ableStyle();
this.dataGridTe xtBoxColumn1 = new
System.Windows. Forms.DataGridT extBoxColumn();
this.dataGridTe xtBoxColumn2 = new
System.Windows. Forms.DataGridT extBoxColumn();
((System.Compon entModel.ISuppo rtInitialize)(t his.dataGrid1)) .BeginInit();
this.SuspendLay out();
//
// dataGrid1
//
this.dataGrid1. DataMember = "";
this.dataGrid1. HeaderForeColor =
System.Drawing. SystemColors.Co ntrolText;
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;
this.dataGrid1. TableStyles.Add Range(new
System.Windows. Forms.DataGridT ableStyle[] {
this.dataGridTa bleStyle1});
//
// dataGridTableSt yle1
//
this.dataGridTa bleStyle1.DataG rid = this.dataGrid1;
this.dataGridTa bleStyle1.GridC olumnStyles.Add Range(new
System.Windows. Forms.DataGridC olumnStyle[] {
this.dataGridTe xtBoxColumn1,
this.dataGridTe xtBoxColumn2});
this.dataGridTa bleStyle1.Heade rForeColor =
System.Drawing. SystemColors.Co ntrolText;
this.dataGridTa bleStyle1.Mappi ngName = "";
//
// dataGridTextBox Column1
//
this.dataGridTe xtBoxColumn1.Fo rmat = "c";
this.dataGridTe xtBoxColumn1.Fo rmatInfo = null;
this.dataGridTe xtBoxColumn1.Ma ppingName = "col1";
this.dataGridTe xtBoxColumn1.Wi dth = 75;
//
// dataGridTextBox Column2
//
this.dataGridTe xtBoxColumn2.Fo rmat = "c";
this.dataGridTe xtBoxColumn2.Fo rmatInfo = null;
this.dataGridTe xtBoxColumn2.Ma ppingName = "col2";
this.dataGridTe xtBoxColumn2.Wi dth = 75;
//
// Form1
//
this.AutoScaleB aseSize = new System.Drawing. Size(5, 13);
this.ClientSize = new System.Drawing. Size(292, 273);
this.Controls.A dd(this.dataGri d1);
this.Name = "Form1";
this.Text = "Form1";
((System.Compon entModel.ISuppo rtInitialize)(t his.dataGrid1)) .EndInit();
this.ResumeLayo ut(false);

}
#endregion
}
}
// To Here:----------------------------------------------

And here's the output
Unhandled Exception: System.NullRefe renceException: 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 (DataGridCell
value)
at System.Windows. Forms.DataGrid. set_CurrentColu mn(Int32 value)
at System.Windows. Forms.DataGrid. ProcessTabKey(K eys keyData)
at System.Windows. Forms.DataGrid. ProcessGridKey( KeyEventArgs ke)
at System.Windows. Forms.DataGrid. ProcessDialogKe y(Keys keyData)
at System.Windows. Forms.Control.P rocessDialogKey (Keys keyData)
at System.Windows. Forms.TextBoxBa se.ProcessDialo gKey(Keys keyData)
at System.Windows. Forms.Control.P reProcessMessag e(Message& msg)
at System.Windows. Forms.ThreadCon text.System.Win dows.Forms.Unsa feNativeMethods +IMsoComponent. FPreTranslateMe ssage(MSG&
msg)
at System.Windows. Forms.Component Manager.System. Windows.Forms.U nsafeNativeMeth ods+IMsoCompone ntManager.FPush MessageLoop(Int 32
dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows. Forms.ThreadCon text.RunMessage LoopInner(Int32
reason, ApplicationCont ext context)
at System.Windows. Forms.ThreadCon text.RunMessage Loop(Int32 reason,
ApplicationCont ext context)
at System.Windows. Forms.Applicati on.RunDialog(Fo rm form)
at System.Windows. Forms.Form.Show Dialog(IWin32Wi ndow owner)
at System.Windows. Forms.Form.Show Dialog()
at Products.App.Ma in(String[] asArgs) in
c:\dotnet\produ ctmigration\pro ducts\classes\a pp.cs:line 53The program
'[1420] Products.exe' has exited with code 0 (0x0).

Regards,
Tamlin.
Jul 21 '05 #3

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

Similar topics

3
4270
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 than 5000) the excel loss format in the last rows mainly in Rowsan or Colspan property for the table. This is the code I'm using Response.Clear(); Response.Buffer=true; Response.ContentType = "application/vnd.ms-excel"; Response.Charset = "";
5
2377
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, check boxes, date pickers, combo boxes and datagrids). I have been coding alone on this project for about a year, and I have experienced many problems which have not been addressed by various SP's, including the recent SP1 to Framework.NET 1.1,...
4
4420
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: 1000098. How do I do that? Thanks
2
1466
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 DBA defined QTY as money. Changing the datatype to Integer in the database isn't an option here so I'm hoping someone can present a workaround. In a datagrid, the data in the fields is written to the aspx page as "1.0000" even though only "1"...
3
2621
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 wrong currency format. Any help will be higly cheered!
6
1795
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
2
2122
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 record, the ComboBoxColumn's Commit event doesn't fire. If the user first edits a TextBox cell on the same New row, and THEN selects a new value for the ComboBox cell, Commit fires. What is going on and how do I get around it Thanks Pat
2
3134
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 want 2). Soooo ... I tried to create the cultureinfo object, set the format decimal digits, then assign that to formatinfo on the column. Anyone see where I went astray? Dim USCultureInfo As CultureInfo = New CultureInfo("en-us")
2
416
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 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.
0
9591
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
9425
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
10057
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...
1
10002
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8883
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...
1
7415
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6676
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();...
2
3575
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2816
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.