471,316 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,316 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 3066
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Henrique Berenguel | last post: by
2 posts views Thread by D. Shane Fowlkes | last post: by
3 posts views Thread by Jensen bredal | last post: by
6 posts views Thread by Beren | last post: by
2 posts views Thread by pmcguire | last post: by

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.