|
Edbert,
thanks for your helping reply. There is no apparent reason NOT to use overloads. I am not that experienced so didn't consider them in the first place.
A few quick questions anyway:
- Would you regard using the overloads as proper design? Say there are 5 different elements I can add to another element. I might end up with 5 overloads.
- What does happen with the former abstract Add() method? It has to be overridden in the inheriting child classes but isn't of much help. Instead the overloads bear the brunt. Just do nothing?
<br />
public class Element1 : BaseClass<br />
{<br />
public override void Add(BaseClass element)<br />
{<br />
}<br />
}<br />
- What do you mean by "These functions can in turn call your private Add() function"? Who is public, who is private?
Your reply was much appreciated!
Goebel
|
|
|
|
|
Yes, overloads are proper design. Heck, it is part of what Object Oriented Programming is about.
Since you're not going to use the Add(BaseClass element) you do not need to declare it in the base class.
You can only override functions with the same signature (i.e. takes same arguments and returns same type).
Even if you leave it in the base class you do not have to override it on child classes that do not need it.
If you do not override it in the child class the function with the particular signature will simply become unavailable for the child class.
Oh, and one more thing, what I meant by calling the private Add() is if your overloads actually do the same thing (has the same code), then you can create a private function that can be called by the overloads and receive the base class instead.
|
|
|
|
|
MailMessage mailMsg = new MailMessage();
mailMsg .From = "from@fromServer.com";
mailMsg .To = "to@toServer.com";
mailMsg .Cc = "cc@ccServer.com"";
mailMsg .Bcc = "bcc@bccServer.com";
mailMsg .Subject = "SubjectOfTheMailString";
mailMsg .Body = "BodyOfTheMailString";
SmtpMail.Send(mailMsg );
How can we know the mail is sent successfully.
Can you show me more methods to know the mail is delivered right. Or we can keep track of process sending mail.
Thx
ngh
|
|
|
|
|
Maybe this:
http://www.levelextreme.net/wconnect/wc.dll?10,7,10,45
can helps
regards
|
|
|
|
|
Hello,
I want to pass over all the opened forms of my application and set the visible property to false, if the form was shown.
How can I do that?
Thanks.
|
|
|
|
|
Whenever you open a form, store the reference to it in some central collection (don't forget to remove after closing the form). Now, if you want to hide all forms, iterate over the collection and assign false to the Visible property.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Can you provide me with some code, please?
|
|
|
|
|
It's almost impossible without knowing your code.
Declare the central form collection where it csn be accessed whenever a fom is opened (either in the main form that opens all other forms or as a static property or class which is always accesssible). If you're using .NEt 2.0 use a generic List as collection otherwise an ArrayList or a custom, typoesafe class derived from CollectionBase .
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
a quick and dirty way:
<br />
using System;<br />
using System.Runtime.InteropServices;<br />
using System.Windows.Forms;<br />
<br />
public class GetFormsCollection {<br />
<br />
private delegate bool WndEnumProc(System.IntPtr hWnd , int lParam);<br />
<br />
[DllImport("user32.dll", CharSet=CharSet.Auto)]<br />
private static extern bool EnumWindows (WndEnumProc lpEnumFunc, int lParam);<br />
<br />
public readonly System.Collections.ArrayList Forms;<br />
<br />
public GetFormsCollection() {<br />
Forms = new System.Collections.ArrayList();<br />
EnumWindows(new WndEnumProc(EnumCallback), 0);<br />
}<br />
<br />
private bool EnumCallback(System.IntPtr hWnd, int lParam) {<br />
<br />
Control hForm = System.Windows.Forms.Control.FromHandle(hWnd);<br />
if (hForm != null) this.Forms.Add(hForm);<br />
return true;<br />
}<br />
<br />
public static void SetVisiblity(bool fVisible) {<br />
<br />
foreach (System.Windows.Forms.Form objForm in new GetFormsCollection().Forms) {<br />
objForm.Visible = fVisible;<br />
}<br />
}<br />
}<br />
Martin
|
|
|
|
|
Thanks a lot, but I got an error:
Unable to cast object of type 'System.Windows.Forms.ToolStripDropDownMenu' to type 'System.Windows.Forms.Form'.
On this line:
foreach (System.Windows.Forms.Form objForm in new GetFormsCollection().Forms)
I'm using .NET 2.0
What wrong?
Thanks.
|
|
|
|
|
oops, I'm using VS 2003 so I can't check that... As I said, it's a quick & dirty way;).
Creating a Forms.Control object from a handle seems to work for some other UI controls (i.e. ToolStripDropDownMenu) that respond to EnumWindows().
However, try to replace the line
Control hForm = System.Windows.Forms.Control.FromHandle(hWnd);
with this one:
System.Windows.Forms.Form hForm = System.Windows.Forms.Control.FromHandle(hWnd) as System.Windows.Forms.Form;
in order to get forms only.
hope that helps
Martin
|
|
|
|
|
Thanks a lot, it worked!
But...
It doesn't hide the print preview dialog of my internal WebBrowser control!
WebBrowser1.ShowPageSetupDialog();
Is there any way to hide that as well?
|
|
|
|
|
ouh... this becomes really complicated. To solve this particular issue, I would suggest to add an eventhandler in your form.
this.VisibleChanged += new EventHandler(Form1_VisibleChanged);
Here you can show/hide the dialog according to the actual form's Visible state.
My solution is a sledgehammer method to get all running form objects - without having any idea of your application logic. Maybe you will run run into similar issues with other forms/controls.
At this point you might consider implementing Stefan's solution and storing your forms references in a central list?
btw: if *all* app's windows (incl. dialogs) were hidden... how to bring them back?
regards
Martin
|
|
|
|
|
Please help me.
Tell me what is the common name of dialog like yahoo (it allow you type and format characters)?
How can I get dialog like that. I need a dialog allow you type and format characters..
I want to add dialog(Richtextbox) to myApplication form. Thx.
ngh
|
|
|
|
|
Thank you all guys. I have found it at http://www.codeproject.com/cs/miscctrl/richtextboxextended.asp
Thank you author a lot...
ngh
|
|
|
|
|
hello,
I have a little question: Does C# 3 gets delivered together with .net framework 3.0 ? Because I installed .net framework 3.0 RC1 and Orcas but I don't get
C# 3 snippets compiled. If it's not in the .net framework 3.0 package can I download the compiler somewhere else, is it already available?
Thank you.
|
|
|
|
|
|
thank you for the clarification.
|
|
|
|
|
VS 2003
C#: Windows Application - OLEDB Connection -->MS Access
Customer Table --> C Dataset
Product Table --> P Dataset
Customer Product Table --> CP Dataset --> Display Datagrid
----------------------------------------
Hi, I have a form that have textfields from Customer Dataset and Product Dataset. How do I update both data into the CP Dataset and display into Datagrid?
|
|
|
|
|
I have a very simple and short application, which is copy/pasted below. Serialization goes perfectly nice. The XML file is being created and it looks correct.
The problem starts when trying to deserialize -> I get an error:
Code:
There is an error in XML document (1, 1).
---------------------------------
This is the programme:
[Serializable]<br />
<br />
publicclassData<br />
<br />
{<br />
<br />
[XmlArrayItem(typeof(string))]<br />
<br />
publicArrayList Pol = newArrayList();<br />
<br />
[XmlArrayItem(typeof(string))]<br />
<br />
publicArrayList Eng = newArrayList();<br />
<br />
[XmlArrayItem(typeof(string))]<br />
<br />
publicArrayList Ger = newArrayList();<br />
<br />
}
<br />
<br />
[Serializable]<br />
<br />
publicclassStoreHouse<br />
<br />
{<br />
<br />
[XmlArrayItem(typeof(Data))]<br />
<br />
publicArrayList DataList = newArrayList();<br />
<br />
}
Serialization part:
Data d = newData();<br />
<br />
d.Eng.Add("1");<br />
<br />
d.Eng.Add("2");<br />
<br />
d.Ger.Add("dadas");<br />
<br />
d.Ger.Add("dsadsadAS");<br />
<br />
d.Pol.Add("dasd");<br />
<br />
d.Pol.Add("etrre");<br />
<br />
d.Pol.Add("trtre");<br />
<br />
sh.DataList.Add(d);<br />
<br />
Data d1 = newData();<br />
<br />
d1.Eng.Add("1321");<br />
<br />
d1.Eng.Add("2ds");<br />
<br />
d1.Ger.Add("ddadadas");<br />
<br />
d1.Ger.Add("dsa123123dsadAS");<br />
<br />
d1.Pol.Add("das31231dasd");<br />
<br />
d1.Pol.Add("et3213rre");<br />
<br />
d1.Pol.Add("t131rtre");<br />
<br />
sh.DataList.Add(d1);<br />
<br />
XmlSerializer s = newXmlSerializer(typeof(StoreHouse));<br />
<br />
s.Serialize(new System.IO.StreamWriter(@"c:\a.xml"), sh);
Deserialization part:
XmlSerializer s = newXmlSerializer(typeof(StoreHouse));<br />
<br />
sh = ((StoreHouse)s.Deserialize(new System.IO.StringReader(@"c:\a.xml")));
What do you think may be wrong?
thank you very much in advance
|
|
|
|
|
GOOGLE: MSDN C# XmlSerializer "error in XML document"
led mike
|
|
|
|
|
I read many MSDN articles regarding serialization issue. I still can`t see mistake. Can you?
|
|
|
|
|
-Yoyosh- wrote: I read many MSDN articles
I don't care how many you read did you read the "one" that I pointed you to? The first one in the search results using my search? Did you read the section titled "Problems Deserializing XML"?
If you did all that why have you not posted the contents of the InnerException so we can help you?
led mike
|
|
|
|
|
I'd like to use an Async. HttpWebRequest for my application (because, i have a long loop and my GUI seem to freeze) but i have to pass a CookieContainer and retrieve it from each request, how can i do? someone can do an example? i can't find anything on the net with Cookies, thank you
|
|
|
|
|
How to get all processes that comunicate via port 80?
thank you for any help
|
|
|
|