|
the IDE notes that :
An unhandled exception of type 'System.NullReferenceException' occurred in system.windows.forms.dll
All codes are bellow:
//-------------------------------------------------
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace test
{
///
/// Summary description for Form1.
///
public class Form1 : System.Windows.Forms.Form
{
private DataTable _table=null;
private DataView _view1=null;
private DataView _view2=null;
private System.Windows.Forms.DataGrid dataGrid1;
private System.Windows.Forms.DataGrid dataGrid2;
///
/// Required designer variable.
///
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
init();
}
private void init()
{
DataColumn C1=new DataColumn("id",typeof(int));
C1.AutoIncrement=true;
DataColumn C2=new DataColumn("name",typeof(string));
DataColumn C3=new DataColumn("age",typeof(int));
this._table=new DataTable("Student");
_table.Columns.Add(C1);
_table.Columns.Add(C2);
_table.Columns.Add(C3);
_view1=new DataView(_table);
_view2=new DataView(_table);
this.dataGrid1.DataSource=_view1;
this.dataGrid2.DataSource=_view2;
_view1.RowFilter="id<10";
_view2.RowFilter="id>=10";
_view1.ListChanged+=new ListChangedEventHandler(_view1_ListChanged);
}
///
/// Clean up any resources being used.
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.dataGrid1 = new System.Windows.Forms.DataGrid();
this.dataGrid2 = new System.Windows.Forms.DataGrid();
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.dataGrid2)).BeginInit();
this.SuspendLayout();
//
// dataGrid1
//
this.dataGrid1.DataMember = "";
this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
this.dataGrid1.Location = new System.Drawing.Point(22, 15);
this.dataGrid1.Name = "dataGrid1";
this.dataGrid1.Size = new System.Drawing.Size(255, 135);
this.dataGrid1.TabIndex = 0;
//
// dataGrid2
//
this.dataGrid2.DataMember = "";
this.dataGrid2.HeaderForeColor = System.Drawing.SystemColors.ControlText;
this.dataGrid2.Location = new System.Drawing.Point(288, 14);
this.dataGrid2.Name = "dataGrid2";
this.dataGrid2.Size = new System.Drawing.Size(282, 138);
this.dataGrid2.TabIndex = 1;
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(605, 319);
this.Controls.Add(this.dataGrid2);
this.Controls.Add(this.dataGrid1);
this.Name = "Form1";
this.Text = "Form1";
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.dataGrid2)).EndInit();
this.ResumeLayout(false);
}
#endregion
///
/// The main entry point for the application.
///
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void _view1_ListChanged(object sender, ListChangedEventArgs e)
{
try
{
_view1.ListChanged-=new ListChangedEventHandler(_view1_ListChanged);
if(e.ListChangedType==ListChangedType.ItemAdded)
{
_view1[e.NewIndex]["age"]=18;
}
_view1.ListChanged+=new ListChangedEventHandler(_view1_ListChanged);
}
catch(Exception Ex)
{
MessageBox.Show(Ex.ToString());
}
}
}
}
//-----------------------------------------------------
|
|
|
|
|
|
hello, I need some help with extending the functionality of the C# save/open file dialogs.
What I would like is to be able to have a file dialog but with some more components than the ones available in the standard open/save dialogs. Now the classes in the Framework are sealed so I can't do it with inheritance. So how do I do it? I really don't know where to start looking.
Can anybody point me in the right direction? It doesn't seem to be the easiest thing to accomplish but it can't be impossible though..
|
|
|
|
|
It looks to me like you can add components using OpenFileDialog.Components.Add(). For Example:
OpenFileDialog opendlg=new OpenFileDialog;
Panel panel=new Panel();
.
.
.
opendlg.Components.Add(panel);
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
It's 6:30pm and it looks like a long night ahead for me. Hopefully someone out there that has had a similar problem can help me.
I am sending emails to our clients via CDO & C#. Here is the code:
CDO.IMessage message = new CDO.MessageClass();
message.TextBody = textbody;
message.HTMLBody = htmlbody;
message.From = fromEmail;
message.To = toEmail;
message.Subject = subject;
message.HTMLBodyPart.ContentTransferEncoding = "7bit";
message.HTMLBodyPart.Fields.Update();
message.Send();
The message is accepted by most SMTP servers, however, some are not accepting the message, claiming that the lines are "not ending with CR/CL". I've been referred to this page by one of the receiving SMTP servers.
"quoted-printable" was not acceptable since it was garbling some of the
links within the email (on links where a dot '.' landed at the end of
the line, before the encoded carriage return. So now I force 7bit encoding and that resolved that issue, however I'm now facing this one.
|
|
|
|
|
I had the same problem when sending plain-text e-mail using the System.Web.Mail.SmtpMail class. The page you were referred to just explains that using bare LF characters (line feed) in an email message sent through SMTP is violation of some specification, and perhaps some SMTP servers seem to tolerate this? (someone who know more about this issue could back me up on this ) I solved the problem by replacing all LF characters by CR-LF (carriage return, line feed) combinations, i.e. if the original string looked like this:
<br />
string textBody="Hello\n\nThis is a message\nThanks";<br />
It should look like this after the correction:
<br />
string textBody="Hello\r\n\r\nThis is a message\r\nThanks";<br />
Hope this helps!
Rado
|
|
|
|
|
Thank you so much for your help Rado!
Do you think the issue is only related to the body of the email, and not the rest of it? Say the mime-headers?
|
|
|
|
|
I'm sorry for the late reply, been pretty busy today. I think that it is related to the whole email message including headers, though I'm not sure. When using the System.Web.Mail.SmtpMail class I never cared about the headers, as this is handled by the class itself, I only had to make sure that the body of the message doesn't contain bare LFs but CR-LF pairs. But I guess that bare LF isn't allowed anywhere in the message.
I hope that you have solved your problems
[EDIT]I did mean the System.Web.Mail.MailMessage class instead of the SmtpMail class [/EDIT]
Rado
|
|
|
|
|
I have searched all over the place to figure out how to run an .exe file from a C# app. Surely there is at least a Windows API out there somewhere that I can call. Can someone help me out?
Darryl Borden
Principal IT Analyst
darryl.borden@elpaso.com
|
|
|
|
|
System.Diagnostics.Process.Start(string fileName);
Flight to Redmond - £200
Bulldozer Rental - £100
Destroying the MS campus single handedly for not doing an Academic upgrade, PRICELESS!
-Jonny Newman
|
|
|
|
|
What about automating the answer to this weekly question ?
|
|
|
|
|
And deprive us of the fun of trying to type the same function name while laughing hysterically?
Flight to Redmond - £200
Bulldozer Rental - £100
Destroying the MS campus single handedly for not doing an Academic upgrade, PRICELESS!
-Jonny Newman
|
|
|
|
|
David Stone wrote:
while laughing hysterically
Seem ready to take a job as a manager. Nice.
|
|
|
|
|
No, I'm not that evil...yet. I just get tired of seeing the exact...same...thing every...single...week.
Flight to Redmond - £200
Bulldozer Rental - £100
Destroying the MS campus single handedly for not doing an Academic upgrade, PRICELESS!
-Jonny Newman
|
|
|
|
|
David Stone wrote:
No, I'm not that evil...yet.
Oh, I see you as a HR manager, saying "I am sorry but, you gave us dedication and life but now take your pink slip" twice a day.
David Stone wrote:
I just get tired of seeing the exact...same...thing every...single...week.
Count me in to add nagged posts just to make you stuck on the C# forum answering the same questions over and over again...
|
|
|
|
|
Stephane Rodriguez. wrote:
Count me in to add nagged posts just to make you stuck on the C# forum answering the same questions over and over again...
Now who's the evil one, eh?
Flight to Redmond - £200
Bulldozer Rental - £100
Destroying the MS campus single handedly for not doing an Academic upgrade, PRICELESS!
-Jonny Newman
|
|
|
|
|
The application which was working fine before, suddenly throwing exceptions.
When I debugged I found this error and it happens in the Main()
An unhandled exception of type 'System.InvalidOperationException' occurred in system.dll
Additional information: Process performance counter is disabled, so the requested operation cannot be performed.
What's the heck is this error?
"If a jug falls upon a stone, woe to the jug. If a stone falls upon a jug, woe to the jug. Always woe to the jug"." - KaЯl This signature was created by "Code Project Quoter".
|
|
|
|
|
|
Have you tried something like (just a shot in the dark):
string proc=Process.GetCurrentProcess().ProcessName.ToString();
-Nick Parker
|
|
|
|
|
As per MSDN, I set the Disable Performance Counters in registry to 0 and it worked.
My question, why all of sudden this error came up?
I will try your tip.
Thx
"If a jug falls upon a stone, woe to the jug. If a stone falls upon a jug, woe to the jug. Always woe to the jug"." - KaЯl This signature was created by "Code Project Quoter".
|
|
|
|
|
Nick Parker wrote:
string proc=Process.GetCurrentProcess().ProcessName.ToString();
Didn't work.
Right now, changing the value in Registry makes it work.
"If a jug falls upon a stone, woe to the jug. If a stone falls upon a jug, woe to the jug. Always woe to the jug"." - KaЯl This signature was created by "Code Project Quoter".
|
|
|
|
|
Kant wrote:
Didn't work.
Hmmm, works for me.
-Nick Parker
|
|
|
|
|
How can I select a part of an image and copy/paste it? Something like Paint and other image editors do.
Mazy
No sig. available now.
|
|
|
|
|
Mazdak wrote:
How can I select a part of an image and copy/paste it? Something like Paint and other image editors do.
Mazy, take a look at Nish's article: Clipboard handling with .NET[^]. He discusses how to do this with the Clipboard.SetDataObject() and Clipboard.GetDataObject() methods.
-Nick Parker
|
|
|
|
|
My message didn't show up on this board because of a bug or something so I'm posting again:
If you put a WebBrowser control in a Form, and then put that Form inside another Form (set it's Parent to the other form and set TopLevel to false, which is perfectly legal according to the docs), then when you quit your application (close the outer Form), it will stay resident in memory and eat up 100% of CPU time. (You can see it doing this in the Task Manager). This is probably caused by that OLEinPlace stuff somehow but I don't know OLE so that's totally a guess.
This is a HUGE problem for me!!
"Outside of a dog, a book is Man’s best friend. And inside of a dog, it’s too dark to read."
-Groucho Marx
|
|
|
|