|
Hi to all,
I have 3 dialogs which are Parent, Dialog and Child. When I press My Parent dialog's menu I come across with my dialog box. Everything ok for now. But when I press the button on dialog I want my child dialog inside the parent dlg box. I think I made something wrong the code runs without any errors but doesn't make what I want??? Might be a logic failure in somewhere. This trashed all my day (I brainstrom and checked lots of articles about forms...) But couldn't get a result. So any help would be greatly appreciated. I am posting all my 3 file(Sorry for the pollution)
Thank you,
Cem Louis
/////////////
//Parent.cs//
/////////////
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace Test1
{
/// <summary>
/// Summary description for Parent.
/// </summary>
public class Parent : System.Windows.Forms.Form
{
private System.Windows.Forms.MainMenu mainMenu1;
private System.Windows.Forms.MenuItem menuItem1;
private System.Windows.Forms.MenuItem menuItem2;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public Parent()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <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.mainMenu1 = new System.Windows.Forms.MainMenu();
this.menuItem1 = new System.Windows.Forms.MenuItem();
this.menuItem2 = new System.Windows.Forms.MenuItem();
//
// mainMenu1
//
this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem1});
//
// menuItem1
//
this.menuItem1.Index = 0;
this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem2});
this.menuItem1.Text = "Show Dialog";
//
// menuItem2
//
this.menuItem2.Index = 0;
this.menuItem2.Text = "Show!";
this.menuItem2.Click += new System.EventHandler(this.menuItem2_Click);
//
// Parent
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 273);
this.IsMdiContainer = true;
this.Menu = this.mainMenu1;
this.Name = "Parent";
this.Text = "Parent";
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Parent());
}
private void menuItem2_Click(object sender, System.EventArgs e)
{
Test1.Dialog Dialog = new Test1.Dialog();
Dialog.Show();
}
}
}
/////////////
//Dialog.cs//
/////////////
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace Test1
{
/// <summary>
/// Summary description for Dialog.
/// </summary>
public class Dialog : System.Windows.Forms.Form
{
private System.Windows.Forms.Button button1;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public Dialog()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <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.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(104, 104);
this.button1.Name = "button1";
this.button1.TabIndex = 0;
this.button1.Text = "Show Child";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// Dialog
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 273);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.button1});
this.Name = "Dialog";
this.Text = "Dialog";
this.ResumeLayout(false);
}
#endregion
private void button1_Click(object sender, System.EventArgs e)
{
Test1.Child chform = new Test1.Child();
Test1.Parent Parent = new Test1.Parent();
chform.MdiParent = Parent;
chform.Show();
}
}
}
////////////
//Child.cs//
////////////
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace Test1
{
/// <summary>
/// Summary description for Child.
/// </summary>
public class Child : System.Windows.Forms.Form
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public Child()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <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.components = new System.ComponentModel.Container();
this.Size = new System.Drawing.Size(300,300);
this.Text = "Child";
}
#endregion
}
}
|
|
|
|
|
Hi,
I think I know the problem.
When you launch the program, you create an instance of the class "parent". But since you do not pass the object to Dialog, you can't refer to it there.
Here's what I did that seemed to produce the effect you want:
1) modify Dialog.cs so that you can store the parent object somewhere. Add this on line 20 or so
<br />
public class Dialog : System.Windows.Forms.Form<br />
<br />
{<br />
private Form MainForm;
<br />
private System.Windows.Forms.Button button1;<br />
2) Modify the constructor for for Dialog so you can pass it a the parent.
<br />
public Dialog(Form frmMain)
{<br />
InitializeComponent();<br />
<br />
this.MainForm = frmMain;
}<br />
<br />
3) Pass the parent object when you instantiate the form...in Parent.cs
<br />
private void menuItem2_Click(object sender, System.EventArgs e)<br />
{<br />
Test1.Dialog Dialog = new Test1.Dialog(this);
Dialog.Show();<br />
}<br />
4) Then (finally!) set the mdiparent for the Child
<br />
private void button1_Click(object sender, System.EventArgs e)<br />
{<br />
Test1.Child chform = new Test1.Child();<br />
chform.MdiParent = this.MainForm;<br />
chform.Show ();<br />
}<br />
Hope this helps! I can send you the source code if this post doesn't get the message across...
Bill
|
|
|
|
|
//bill dean says kids, stay in school
I, for one, do not think the problem was that the band was down. I think that the problem may have been that there was a Stonehenge monument on the stage that was in danger of being crushed by a dwarf.
-David St. Hubbins
|
|
|
|
|
Hi Bill,
Thank you very much, I don't need the source, I got the idea...
Thank you again.
Cem Louis
|
|
|
|
|
Hello,
I am interested in creating a program to handle large a mailing list and help eliminated bounced messages by doing e-mail validation. I've looked at articles on this site and elsewhere on the web, and it appears that most of the validation approaches include validating the e-mail address syntax with regular expressions, then validating that the domain exists, then connecting to the smtp server and making sure that it will accept mail for a certain address. However, I have read that this will not work for some e-mail providers, such as aol, hotmail, servers based on ms outlook, etc. and that the only way to find out if an e-mail address is really valid for these is to wait and see if the message bounces back.
Does anyone know of a sure way to validate all e-mail addresses, or is it just not possible?
I guess if there is no 100% correct way, then I can try to combine the two approaches by first checking addresses by contacting the smtp server, and then also analyzing bounced messages.
Thanks for any input.
Blake
|
|
|
|
|
I did this for a large email list, and in the end, it was mostly a waste of time. You can forget getting anything from AOL. When I tried it, hotmail and msn actually did verify the addresses. I'm not sure if that's still true.
You end up creating a fairly complicated program to handle all of the conditions (couldn't find the MX record, couldn't connect to any of the given MX's, try again later? how many times?).
You'll get so many false positives (SMTP servers that say "sure, I'll send email to fred@... when fred doesn't exist). Depending on your connection, you'll also run into servers that won't even allow you to connect ("you're on a cable modem? you have no business trying to relay mail...").
Don't get me wrong, it's a pretty fun project. Just don't expect to get too much valuable information from it .
I, for one, do not think the problem was that the band was down. I think that the problem may have been that there was a Stonehenge monument on the stage that was in danger of being crushed by a dwarf.
-David St. Hubbins
|
|
|
|
|
You can validate the actual email address string. There is an RFC that defines valid addresses. The regex string below is the most common:
^[\w\.\-]+@[a-zA-Z0-9\-]+(\.[a-zA-Z0-9\-]{1,})*(\.[a-zA-Z]{2,3}){1,2}$ As far as validating the MX records, the other poster was correct that it's not 100% effective, but it's at least worth a shot (while you may get false positives, you will get correct rejections). See http://www.codeproject.com/aspnet/emailvalidator.asp[^] for a good article on MX validation, although there are others. Just try this search[^] (watch the ratings to filter the bad ones).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
From what I understand, the RFC allows a LOT of crap that "nobody" uses. For instance, fred@123.123.123.123 (IP address) is supported in the RFC.
There's also a lot of people who try to check things like the length of the TLD (2 - 6 characters for the museum TLD).
I'm currently using the regular expression here. It's a pretty decent one. Also notice how many submissions there are on that site for email regular expressions. Some people stick to the RFC and some people realize the RFC is not quite restrictive enough for "real" usage.
I, for one, do not think the problem was that the band was down. I think that the problem may have been that there was a Stonehenge monument on the stage that was in danger of being crushed by a dwarf.
-David St. Hubbins
|
|
|
|
|
Can I use that mx validator component in a C# program?
|
|
|
|
|
Unmodified, no. A validator in ASP.NET takes the name of a control which it finds in in the control collection of the container. This wouldn't work for Windows Forms. You can use the code, though. There's other code out there as well, including an MX validator I wrote a long time ago that I believe I posted in this C# forum over a year ago. Good luck finding it, though. In any case, DNS queries are a standard so the only real difference in code is how you do it.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Blake,
Just my two cents. I had this same problem where I work with a list of over 2 million. The final solution that I implemented was to send all of the emails with a unique identifier in the return address. Like so: member_number@yourdomain.com.
Then when a bounce occurs, the email will come back to our server. I use exchange so I had to write an event sink to parse the email address that was coming in and get the member number from whence it bounced and then update that member's email valid in our database. Not sure if this will work for you depending on your setup.
It was tricky but we have it running perfectly now and we now bounce only 2% of our very large lists. One thing we had to keep in my mind was that there are different types of bounces, hard, soft, etc... Most mail servers will send this information back to you in the "bounce" email header and it is up to you to handle it accordingly. For us, we allow 3 soft bounces or one hard.
Like I said, it was a little tricky but we cut our bounces down DRAMATICALLY. If you are interested in the details and some sample code, just reply here and I will get it to you.
Thanks,
Troy G
|
|
|
|
|
Troy,
This is exactly what I have been thinking about doing (I read an article about it on this website), and I thought that I might even combine it with the MX checking that other people had posted about.
I would love to see some details and code if you want to send it to me. Maybe I can figure out a way to make it work for our purposes. You can send it to blakeb_1@hotmail.com
Thanks a lot
Blake
|
|
|
|
|
Troy,
Actually, I've just realized that this isn't going to work because the mailing list program we are using isn't going to allow to do any extra programming.
I think I might just stick to verifying through the smtp servers for now, and hopefully it will at least cut down on a little of the bounces. Thanks for offering to send some code though.
Blake
|
|
|
|
|
Hi Troy G,
I am working on a project where i need to track bounced mails and update the database with types of bounce. I am able to send a unique identifier in the return address. Each time there is abounce the mail with the unique identifier is there in the bounce box. Now, the problem is reading the Headers like the member_number in member_number@yourdomain.com and the bounce type and updating it to the database. If u have any idea or code that can do this, then it would really be a great help.
I am interested in getting the details. Thanking you in advance.
With Warm Regards,
Arvind
|
|
|
|
|
I created a control based on pictureBox with transparency. Worked great until I openned the Windows 2000 task manager. Blam, the transparency is gone! Fiddled for a while and got it back, tried the task manager again and blam, transparncy is gone again. The same executable still has transparency in XP.
Whazup?
Thanks in advance.
|
|
|
|
|
Are you using TransparentBackground style? If so, overrice CreateParams, so if the window does need to recreate it self, it will do so properly.
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
Yes, I'm using the TransparentBackground style and I'll try your suggestion. This seems to be related to the CLR attaching the debug stuff to the program. It seems that in Windows 2000, when the debugger is running in the background the transparency is off, but if it isn't running the debugger, the transparency is on. I'll continue to investigate, unless somebody already knows the answer.
Thanks,
Joe
|
|
|
|
|
I have an inherited dialog, that wont fire the validating and validated events for the form, or the inherited yes no buttons. They do have causes validation set to true, in both the base class and the child class. I also have some other input fields that are not inherited from the base control and their validating and validated events are fired just fine. I tried manually hooking up the events from base class to inherited class, with no luck. Any suggestions?
Thanks,
Ryan
|
|
|
|
|
Overriding base class methods and not calling the base class's method will cause this.
override void OnValidate(EventArgs e)
{
base.OnValidate(e);
}
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
I tried to make a private method virtual, and got the following error:
error CS0621: '***' : virtual or abstract members cannot be private
Is it really possible that private methods can not be virtual in C#, or I am making some terrible mistake here?
Thanks.
|
|
|
|
|
Look at the protected keyword...
I, for one, do not think the problem was that the band was down. I think that the problem may have been that there was a Stonehenge monument on the stage that was in danger of being crushed by a dwarf.
-David St. Hubbins
|
|
|
|
|
Use protected . Private members are only accessible to that class, so how can a derivate class override them?
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Heath Stewart wrote:
Private members are only accessible to that class, so how can a derivate class override them?
What do you mean? Virtuality has nothing to do with access rights. In C++ it is perfectly legal (and useful) to override a virtual private function.
Anyway, after googling a little bit, I found out[^] that even CLR supports private virtual methods, and that this is a C# restriction
|
|
|
|
|
Exactly - because it doesn't make any sense. If you RTFD for the C# specification, you'd know this. And it does have to do with access rights because a private member cannot be accessed by either the base or derivative classes so it can't be overridden. Since it can't be overridden, there's no need to mark it virtual! It may be allowed in IL, but it certainly doesn't make sense and hence C# restricts it. This explanation is even given in the C# language documentation.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Heath Stewart wrote:
because a private member cannot be accessed by either the base or derivative classes so it can't be overridden.
I may be stupid, but why a method can't be overriden if it can not be accessed? What one has to do with another?
[edit]
BTW, take a look at this article[^] if you don't know why overriding private members is useful.
[/edit]
Also, I did read the C# language spec. but can't recall any mention of this. Would you tell me exactly where this was mentioned?
|
|
|
|
|