|
hi all,
I am presently creating a text editor for c# .In that application I would like to include one help file in the menu item for c#.I have written the help file in notepad and now when I click the c# menuitem it should open the help notepad to the viewer.
can anyone tell me how to do this.
Don't wait to hear a word of thanks from anybody when you help them instead ask them to help three other people and ask them to continue in chain.
|
|
|
|
|
process.start can be used to open a file with the default program.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi,
I am working on simple file downloader but I got stuck, I dont know how to limit speed of download ?
Is there any way to limit download speed ?
|
|
|
|
|
I want to draw a line on the panel of another form(such as Form2),part of
the code :
private void button3_Click(object sender, EventArgs e)
{
Form2 form = new Form2();
Graphics graphics = form.panel1.CreateGraphics();
graphics.Clear(System.Drawing.SystemColors.Control);
Font drawFont = new Font("Arial", 10);
SolidBrush drawBrush = new SolidBrush(Color.Red);
Pen pen = new Pen(drawBrush);
graphics.DrawLine(pen, 0, 0, 100, 100);
form.ShowDialog();
}
But I couldn't see the red line,I don't know why.
Thanks for your help!
|
|
|
|
|
Try this
private void button3_Click(object sender, EventArgs e)
{
Form2 form = new Form2();
Graphics graphics = form.panel1.CreateGraphics();
graphics.Clear(System.Drawing.SystemColors.Control);
Font drawFont = new Font("Arial", 10);
SolidBrush drawBrush = new SolidBrush(Color.Red);
Pen pen = new Pen(drawBrush);
form.Show();
graphics.DrawLine(pen, 0, 0, 100, 100);
}
|
|
|
|
|
Thank you very much!But when I move the Form2,the line disappear.
|
|
|
|
|
That is because the form gets damaged. You have to redraw the line each time the form gets damaged.
|
|
|
|
|
You're confusing the concept of "drawing a line" with "creating a static line control". Drawing is done in response to a paint message by Windows. The call to form.Dialog() causes the instance of Form2 to repaint itself. Since the form doesn't contain a red panel with a red line, it isn't shown when the form is displayed.
/ravi
|
|
|
|
|
Thank you very much!But could you conduct me to solve the problem,"creating a static line control".
|
|
|
|
|
After making an executable program in Visual .NET C#.
I click to the icon of the program and the windows is appearing.
And I click second time, the another copy of the program is appearing.
I'd like to avoid from opening copy of the program even after clicking to the
icon of the program.
How to avoid from copy of windows.
|
|
|
|
|
Hi,
just use the search[^] function.
Robert
|
|
|
|
|
Search the forums and articles for "single instance", these are the right keywords you are looking for.
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
u would have to use MUTEX variable to maintainn single instance
|
|
|
|
|
Hi,
I want to know how to create my own public & private key pairs, is it correct to use the following codes? And what are valid parameters P, Q, Modulus, any sample codes?
----------------------------------------------------------------------
RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(1024);
System.Security.Cryptography.RSAParameters parameters = new System.Security.Cryptography.RSAParameters();
parameters.P=???;
parameters.Modulus=???;
.............
...............
rsa.ImportParameters(parameters)
----------------------------------------------------------------------
Thanks & best regards,
Ed.
|
|
|
|
|
I have a Problem To add dynamic control to the Form
i save the controls in array list but when i add the control to Form The added ( the count property of this.Controls updated) But they areen' add to Form ( can't see any thing)
my code is :
int count = 1;
foreach (MyControl _control in ArrayList)
{
this.Controls.Add(_control);
_control.Location = new Point(count * 20, count *20);
count++;
}
What's The Problem
?
With Thanks
MHF
|
|
|
|
|
Hi,
I would first check if the Size and Visible properties of the added controls are correct. Other than that the code principally looks fine.
Robert
|
|
|
|
|
I think Problem is that i read the control's data from ArrayList
because when i use the 'new' keyword that's work
if is it true ?
With Thanks
MHF
|
|
|
|
|
The following is a question i faced in an interview...They asked me the ouput of the following code snippet
using System;<br />
<br />
namespace CsharpTestQ<br />
{<br />
public class ClassA<br />
{<br />
public virtual void printStr()<br />
{<br />
Console.Write("A");<br />
}<br />
}<br />
<br />
public class ClassB:ClassA<br />
{<br />
public override void printStr()<br />
{<br />
Console.Write("B");<br />
}<br />
}<br />
<br />
public class ClassC:ClassB<br />
{<br />
public virtual void printStr()<br />
{<br />
Console.Write("C");<br />
}<br />
}<br />
<br />
public class ClassD:ClassC<br />
{<br />
public override void printStr()<br />
{<br />
Console.Write("D");<br />
}<br />
}<br />
<br />
class Class1<br />
{<br />
<br />
[STAThread]<br />
static void Main(string[] args)<br />
{<br />
<br />
ClassD d=new ClassD();<br />
ClassA a=d;<br />
ClassB b=d;<br />
ClassC c=d;<br />
<br />
a.printStr();<br />
b.printStr();<br />
c.printStr();<br />
d.printStr();<br />
<br />
Console.ReadLine();<br />
<br />
}<br />
}<br />
}
I thought it would be "DDDD" since the object is the same (d) and the vtable in "d" points to the function printStr in ClassD. But when i tried it, the output is "BBDD". Can any one explain what is happening here?
|
|
|
|
|
Hi,
class C shadows the printStr function and thus every call on C or D will call the new function. When compiling this I would think the C# compiler should give out a warning, because normally a explicit new should be put onto the shadowing method declaration.
Robert
|
|
|
|
|
Hi,
Thanks for the reply.
Does this mean that when an object of ClassD is created there's actually two implementation of "printStr" (old and new)within the object? how does the runtime determine which function to call?
Jithu
|
|
|
|
|
Hi,
the implementation of the function is not hold within the object, but yes the class has two different implementations. Which one is called is already determined at compile time. There is another fancy behavior like this when working with explicit interface implementations:
public interface ITest {
public string GetString();
}
public class TestClass : ITest {
public string GetString() {
return "A";
}
string ITest.GetString() {
return "B";
}
}
Now guess what the output of the following code is...
TestClass testClass = new TestClass();
ITest testInterface = testClass;
Console.Write(testClass.GetString());
Console.Write(testInterface .GetString());
The output is AB .
Robert
|
|
|
|
|
Hi,
Thanks!!!
Basic Inheritance in itself is difficult...and these fancy feautures aren't making things easier...
When do we apply these concepts of Shadowing and explicit interface in our code?
Jithu
|
|
|
|
|
Hi,
explicit interface implementations are nice for interfaces like IClonable . The Clone method of IClonable always returns an object (I know there is also a generic version but thats another story). But in most case you also want a typesafe version. With explicit interface implementation you can implement ICloneable while still supplying a typesafe Clone method:
public class Test : IClonable {
public Test Clone() {
}
IClonable.Clone() {
return this.Clone();
}
}
So if you call clone on a variable typed to Test you will also get a Test instance while you'll get an object when working on the interface.
Shadowing can also be useful. Lets assume you have an interface which has a Name property. Lets also assume you have some user control which should implement this interface. Now you have the problem that the Name property from the user control (inherited from Control ) does have a complete different meaning than the Name property of your interface. You could even break the designer when changing the normal Name property. Thus you could either use explicit interface implementation (see above) or use shadowing. When using the new keyword on your Name property it will look like a normal property and can be used as an implicit interface implementation. But everyone using the Name property from a Control typed variable (like the designer does) still gets the same behaviour as before.
Robert
|
|
|
|
|
Thanks...The examples were gr8...Now i have got some idea where to apply the concepts...
|
|
|
|
|
Great, this is a classic concept.
ClassD d=new ClassD();
ClassA a=d;
ClassB b=d;
ClassC c=d;
let me explain the above four lines..
ClassD d=new ClassD(); // Straight fwd..
ClassA a=d; // here we get a reference of ClassD's object in typeof(ClassA)
note that ClassD inherits A,B,C.
now when u call a.get(), the call is forwarded to B.GetString and stops in here, cos the method in c is totally a new one,.
ClassB b=d; here B.GetString() excecutes.
ClassC c=d; -- C.getString is called and it forwards the call to D.getstring.
|
|
|
|