473,385 Members | 1,693 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,385 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.Add(loTable.NewRow());
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 3222
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.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
dataGridTextBoxColumn1;
private System.Windows.Forms.DataGridTextBoxColumn
dataGridTextBoxColumn2;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;

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

//
// 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();
loTable.Rows.Add(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.Dispose();
}
}
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
System.Windows.Forms.DataGridTableStyle();
this.dataGridTextBoxColumn1 = new
System.Windows.Forms.DataGridTextBoxColumn();
this.dataGridTextBoxColumn2 = new
System.Windows.Forms.DataGridTextBoxColumn();
((System.ComponentModel.ISupportInitialize)(this.d ataGrid1)).BeginInit();
this.SuspendLayout();
//
// dataGrid1
//
this.dataGrid1.DataMember = "";
this.dataGrid1.HeaderForeColor =
System.Drawing.SystemColors.ControlText;
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.AddRange(new
System.Windows.Forms.DataGridTableStyle[] {
this.dataGridTableStyle1});
//
// dataGridTableStyle1
//
this.dataGridTableStyle1.DataGrid = this.dataGrid1;
this.dataGridTableStyle1.GridColumnStyles.AddRange (new
System.Windows.Forms.DataGridColumnStyle[] {
this.dataGridTextBoxColumn1,
this.dataGridTextBoxColumn2});
this.dataGridTableStyle1.HeaderForeColor =
System.Drawing.SystemColors.ControlText;
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.Controls.Add(this.dataGrid1);
this.Name = "Form1";
this.Text = "Form1";
((System.ComponentModel.ISupportInitialize)(this.d ataGrid1)).EndInit();
this.ResumeLayout(false);

}
#endregion
}
}
// 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
value)
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&
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).

Regards,
Tamlin.
Jul 21 '05 #3

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

Similar topics

3
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...
5
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,...
4
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:...
2
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...
3
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...
6
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
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...
2
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...
2
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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,...
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.