返回是System.NullReferenceException异常!
解决方案 »
- winfrom程序中,给Panel.BackgroundImage设置大图片后,拉动滚动条后,背景图破碎形成百叶窗效果,如何解决
- 怎么在类中直接修改FORM窗体中的控件属性
- 关于用户自定义控件的问题
- webclient下载地址
- 请教个读取XML内容到类的问题!
- 用c#.net做的网站,在本机上测试,button按扭连接的页面可以跳转,可能把它放到其他机子上就不行了,点击按扭没有反映,为什么啊,在线等
- 连续发送图片,重传机制怎么建立,求指导
- 如何在openFileDialog控件中实现拖动文件?
- 请问那里有webbrowser控件的详细介绍?给分
- 用的英文版的vs.net开发环境版本是7。0。9466这是正式版嘛?另外我的.net Fraemework的版本是1.0.3705,但是里面的控件是1。0。3300,这是
- 哪有C# Primer Plus电子书下载啊?
- C#中怎么使用水晶报表啊?
private void insertDataTable()
{
DataRow dr;
for(int i=0; i<1000; i++)
{
dr = QuotationTable.NewRow(); for(int j=0; j<4; j++)
{
dr[j] = (object)i;
} QuotationTable.Rows.Add(dr);
}
MessageBox.Show("OK");
}
删除掉,运行后还是抛出异常
谢谢提醒。这对优化有很多的帮助。--------------------
但程序还是运行不行
using System.Data;
using System.Threading;
using System.Data.SqlClient;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using dataBase;namespace LanxeSoft
{
/// <summary>
/// Quotation 的摘要说明。
/// </summary>
public class Quotation : System.Windows.Forms.Form
{
private System.Windows.Forms.DataGrid dgQuotation;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
private IList QuotationItemIndex;
private IList QuotationItemname;
private DataTable QuotationTable = new DataTable("QuotationTableList");
private DataTable reDataTable = null;
private Thread td; public Quotation(IList QuotationItemIndex, IList QuotationItemname)
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent(); //
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
this.QuotationItemIndex = QuotationItemIndex;
this.QuotationItemname = QuotationItemname;
CreatQuotationTableStruction();
} private void CreatQuotationTableStruction()
{
if(QuotationItemIndex.Count == 0 || QuotationItemname.Count == 0)
{
MessageBox.Show("建立报表结构出现参数不全错误",getDataBase.MessageBoxShowTitle,MessageBoxButtons.OK,MessageBoxIcon.Warning);
this.Dispose();
}
for(int i=0; i<QuotationItemname.Count; i++)
{
QuotationTable.Columns.Add(new DataColumn((string)QuotationItemname[i],typeof(string)));
} dgQuotation.DataSource = QuotationTable;
} /// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
} #region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Quotation));
this.dgQuotation = new System.Windows.Forms.DataGrid();
((System.ComponentModel.ISupportInitialize)(this.dgQuotation)).BeginInit();
this.SuspendLayout();
//
// dgQuotation
//
this.dgQuotation.CaptionVisible = false;
this.dgQuotation.DataMember = "";
this.dgQuotation.Dock = System.Windows.Forms.DockStyle.Fill;
this.dgQuotation.HeaderForeColor = System.Drawing.SystemColors.ControlText;
this.dgQuotation.Location = new System.Drawing.Point(0, 0);
this.dgQuotation.Name = "dgQuotation";
this.dgQuotation.Size = new System.Drawing.Size(640, 349);
this.dgQuotation.TabIndex = 0;
//
// Quotation
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(640, 349);
this.Controls.Add(this.dgQuotation);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "Quotation";
this.Text = "Quotation";
((System.ComponentModel.ISupportInitialize)(this.dgQuotation)).EndInit();
this.ResumeLayout(false); }
#endregion public void AddNewQuotationProduct()
{
td = new Thread(new ThreadStart(insertDataTable));
td.Name = "tdQuotation";
td.Start();
} private void insertDataTable()
{
DataRow dr;
for(int i=0; i<1000; i++)
{
dr = QuotationTable.NewRow(); for(int j=0; j<4; j++)
{
dr[j] = (object)i;
} QuotationTable.Rows.Add(dr);
}
MessageBox.Show("OK");
} }
}
这是全部代码
private System.Windows.Forms.DataGrid dgQuotation;
private IList QuotationItemIndex;
private IList QuotationItemname;
private DataTable QuotationTable = new DataTable("QuotationTableList");
private DataTable reDataTable = null;
private Thread td;public Quotation(IList QuotationItemIndex, IList QuotationItemname)
{
InitializeComponent(); this.QuotationItemIndex = QuotationItemIndex;
this.QuotationItemname = QuotationItemname;
CreatQuotationTableStruction();
}private void CreatQuotationTableStruction()
{
if(QuotationItemIndex.Count == 0 || QuotationItemname.Count == 0)
{
MessageBox.Show("建立报表结构出现参数不全错误",getDataBase.MessageBoxShowTitle,MessageBoxButtons.OK,MessageBoxIcon.Warning);
this.Dispose();
}
for(int i=0; i<QuotationItemname.Count; i++)
{
QuotationTable.Columns.Add(new DataColumn((string)QuotationItemname[i],typeof(string)));
} dgQuotation.DataSource = QuotationTable;
}public void AddNewQuotationProduct()
{
td = new Thread(new ThreadStart(insertDataTable));
td.Name = "tdQuotation";
td.Start();
}private void insertDataTable()
{
DataRow dr;
for(int i=0; i<1000; i++)
{
dr = QuotationTable.NewRow(); for(int j=0; j<4; j++)
{
dr[j] = (object)i;
} QuotationTable.Rows.Add(dr);
}
MessageBox.Show("OK");
}